Code: Select all
$signature = base64_encode(hash_hmac("sha256",$request,SECRET_ACCESS_KEY,TRUE));
Thanks!
Code: Select all
$signature = base64_encode(hash_hmac("sha256",$request,SECRET_ACCESS_KEY,TRUE));
Code: Select all
(import library "SHA256")
;; @syntax (crypto:sha256 <string> <bool-raw>)
;; @param <string> The string buffer for which to calculate a SHA-256 hash
;; @param <bool-raw> Return the raw binay buffer when 'true'.
;; @return The 32 Byte SHA-1 hash as a 64 Byte long hex string or as a 32 byte binary buffer.
;; @example
;; (crypto:sha256 "ABC") => "3c01bdbb26f358bab27f267924aa2c9a03fcfdb8"
;;
;; (crypto:sha256 (read-file "newlisp-9.1.0.tgz")) => "2127a9c487f338b00f36cfd60b5f33d27b8d0010"
(define (sha256 str raw-flag)
(if raw-flag
(let (buff (dup "\000" 32))
(cpymem (SHA256 str (length str) 0) buff 20)
buff)
(join
(map (lambda (x) (format "%02x" (& x 0xff)))
(unpack (dup "c" 32) (SHA256 str (length str) 0)))
)
)
)
Code: Select all
(println (crypto:sha256 "The quick brown fox jumps over the lazy dog" false))
d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592
(println (crypto:sha256 "The quick brown fox jumps over the lazy dog." false))
ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c