Fork me on GitHub
#announcements
<
2022-10-02
>
Flow15:10:30

I’ve written here about secrets.clj already, a year or two ago. But I’ve improved things since then, so may be someone will find it useful. https://github.com/lk-geimfari/secrets.clj designed to generate random numbers suitable for security purposes. It has API which is similar to Python’s https://docs.python.org/3/library/secrets.html module:

user=> (sc/token-hex 32)
"2aa5430064918acf140bb423678cef7353f7055597bc61305414c5371106ebef"

user=> (sc/token-urlsafe 32)
"kfbGVrB6jz6hyOl_2rX9UIHgiop2-rM_jo2XEK7oTj0"

user=> (sc/token-bytes 16)
#object["[B" 0x3b2454e9 "[B@3b2454e9"]

user=> (sc/randbelow 100)
71

user=> (sc/choice [8 16 32 64 128])
8

user=> (sc/choices [8 16 32 64 128] 2)
(128 16)
The library is dead simple, but may be still useful for managing secrets. Source: https://github.com/lk-geimfari/secrets.clj Feature requests are welcomed, of course. Thank you’ll for attention 😊.

🎉 9
Linus Ericsson09:10:40

Consider using https://docs.oracle.com/javase/8/docs/api/java/security/SecureRandom.html#getInstanceStrong-- instead of the (wesk) sha1prng that is the default in secureRandom.

Flow15:10:16

I’ll take a look. Thank you very much! ❤️

Flow15:10:01

I’ve created an issue: https://github.com/lk-geimfari/secrets.clj/issues/11 I’ll fix it soon. Thank you again!