Skip to content

Latest commit

 

History

History
41 lines (30 loc) · 1.25 KB

0146-crypto-shortcuts.org

File metadata and controls

41 lines (30 loc) · 1.25 KB

crypto-shortcuts

Crypto-shortcuts serves a single purpose - to reduce an amount of headache when you have to encrypt, decrypt or make some kind of hash.

This @Shinmera’s library has a nice documentation. Today I lack time, so here is the only one example of making a sha256 hash out of string.

This code which uses plain flexi-streams and ironclad:

POFTHEDAY> (let* ((octets (flexi-streams:string-to-octets
                           "Hello World!"
                           :external-format :utf-8))
                  (digest (ironclad:digest-sequence
                           'ironclad:sha256
                           octets)))
             (ironclad:byte-array-to-hex-string digest))
"7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069"

Compare it with the code, using crypto-shortcuts:

POFTHEDAY> (cryptos:sha256 "Hello World!")
"7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069"

This library definitely should be in a toolbox of any common-lisper!