Kitura / Kitura/BlueCryptor

Request: Random.generate(hexCharacterCount:)

Open
#18 0 comments 0 reactions 1 assignee Claimed by @adam-rocska View on GitHub
enhancement
Dominant language
Swift
Stars
192
Forks
48
PR merge metrics
No merged PRs in 30d

Description

The `Random.generate(byteCount:)` is a useful way of generating random bytes, but in my own work I found I was mostly using it to generate random strings for encryption purposes. This meant every call to `Random.generate(byteCount:)` was followed by a call to `CryptoUtils.hexString(from:)` to get a Swift string rather than just bytes.

If you could implement a `Random.generate(hexCharacterCount:)` method that combined the two together, it would be most appreciated. If this were combined with #17, then this code:

if let randomBytes = try? Random.generate(byteCount: 64) {
randomString = CryptoUtils.hexString(from: randomBytes)
} else {
randomString = generateMyOwnRandomStringSomehow()
}

Would become simply this:

randomString = Random.generate(hexCharacterCount: 128)

(Note: There may well be a better name for this method.)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.