I guess the RIPEMD160 can be added too to the crypto.lsp..
not that difficult to add (actualy the same as sha1 ;-) but ripemd160 is sometimes used instead of md5, just handy to have..
I only tested it on Win32 with GnuWin32 but i assume itll run unix too,
can check it later today..
I cant find the SHA256 inside the openssl lib actualy, did you had a look at
that perhpas?
Code: Select all
(import library "RIPEMD160")
...
...
...
;; @syntax (crypto:ripemd160 <string> <bool-raw>)
;; @param <string> The string buffer for which to calculate a RIPEMD160 hash
;; @param <bool-raw> Return the raw binay buffer when 'true'.
;; @return The 20 Byte RIPEMD160 hash as a 40 Byte long hex string or as a 20 byte binary buffer.
;; @example
;; (crypto:ripemd160 "ABC") => "df62d400e51d3582d53c2d89cfeb6e10d32a3ca6"
;;
;; (crypto:ripemd160 (read-file "newlisp.exe")) => "9c1185a5c5e9fc54612808977ee8f548b2258d31"
(define (ripemd160 str raw-flag)
(if raw-flag
(let (buff (dup "\000" 20))
(cpymem (RIPEMD160 str (length str) 0) buff 20)
buff)
(join
(map (lambda (x) (format "%02x" (& x 0xff)))
(unpack (dup "c" 20) (RIPEMD160 str (length str) 0)))
)
)
)