janet-lang / pkgs

A package listing for Janet.
MIT License
59 stars 25 forks source link

Add openssl-hash #60

Closed wooosh closed 11 months ago

sogaiu commented 11 months ago

I gave it a try on Linux:

Janet 1.32.1-9593c930 linux/x64/gcc - '(doc)' for help
repl:1:> (import openssl-hash)
@{_ @{:value <cycle 0>} openssl-hash/feed @{:private true} openssl-hash/finalize @{:private true} openssl-hash/new @{:private true}}
repl:2:> (def my-hasher (openssl-hash/new "SHA256"))
<openssl-hash/hasher 0x56225C17A780>
repl:3:> (openssl-hash/feed my-hasher "hello world")
<openssl-hash/hasher 0x56225C17A780>
repl:4:> (print (openssl-hash/finalize my-hasher :hex))
B94D27B9934D3E08A52E52D7DA7DABFAC484EFE37A5380EE9088F7ACE2EFCDE9
nil

All tests passed here:

$ jpm -l test
running test/test.janet ...
✓ All tests passed.
pepe commented 11 months ago

I am sorry, I had forgotten about this PR. My bad.

I have tried it, and it seems to work. Thanks @sogaiu as always.