More sensible conversion of byte-buffer to array

This commit is contained in:
Shane Kilkelly 2017-10-27 10:38:55 +01:00
parent ec94e59388
commit 83bd78f467

View file

@ -15,10 +15,9 @@ module.exports = ProjectTokenGenerator =
TOKEN_NUMERICS: '123456789'
_randomString: (length, alphabet) ->
result = ''
crypto.randomBytes(length).map(
(b) -> result += alphabet[b % alphabet.length]
)
result = crypto.randomBytes(length).toJSON().data.map(
(b) -> alphabet[b % alphabet.length]
).join('')
return result
# Generate a 12-char token with only characters from TOKEN_ALPHA,