I can use SHA256 in Scheme using external libraries (Java, C or system dependent) or using a specific Scheme implementation (like Chicken e.g.), but I wonder if there is a "pure" scheme implementation.
相关问题
- facebook error invalid key hash for some devices
- Generating powerset in one function, no explicit r
- What is fixed point?
- Change first key of multi-dimensional Hash in perl
- How to Hex Encode a SHA-256 Hash
相关文章
- Bcrypt vs Hash in laravel
- Asynchronous SHA256 Hashing
- Does learning one Lisp help in learning the other?
- What is the fastest way to map group names of nump
- What is the definition of “natural recursion”?
- Finding out whether there exist two identical subs
- Oracle STANDARD_HASH not available in PLSQL?
- Looking for a fast hash-function
I wrote an implementation today. Alas, R5RS has neither bytevectors nor binary I/O, so this uses the R7RS APIs for bytevectors and binary I/O. It should be easy to bridge those APIs to your Scheme implementation's native APIs (for example, I actually tested my implementation on Racket and Guile).
A few notes:
Anyway, without further ado, here it is (also available as a Gist):
I implemented all the algorithms in FIPS 180-4, but you can strip out whatever you don't need.
As mentioned before, I tested this on Racket; the definitions I added to bridge to Racket's APIs are as follows:
And here are the definitions for Guile (requires version 2.0.11 or above):
It should be easy to make something similar for your chosen implementation.
I also have a function that prints out the output as a hex string, for ready comparison with various command-line SHA-1 and SHA-2 utilities (e.g.,
sha1sum
,sha256sum
,sha512sum
, etc.):