SHA and SHA-2
1 SHA
sha1
sha224
sha256
sha384
sha512
2 HMAC-SHA
hmac-sha1
hmac-sha224
hmac-sha256
hmac-sha384
hmac-sha512
3 Hex string
bytes->hex-string
4 Predicates for contracts
sha1?
sha224?
sha256?
sha384?
sha512?
6.12

SHA and SHA-2

 (require sha) package: sha

Provides a Racket interface to the OpenSSL implementation of SHA-1 and SHA-2.

SHA-2 includes four flavors: SHA-224, SHA-256, SHA-384, and SHA-512.

1 SHA

procedure

(sha1 bstr)  sha1?

  bstr : bytes?

procedure

(sha224 bstr)  sha224?

  bstr : bytes?

procedure

(sha256 bstr)  sha256?

  bstr : bytes?

procedure

(sha384 bstr)  sha384?

  bstr : bytes?

procedure

(sha512 bstr)  sha512?

  bstr : bytes?
Calculate the SHA hash of bstr.

2 HMAC-SHA

procedure

(hmac-sha1 key data)  sha1?

  key : bytes?
  data : bytes?

procedure

(hmac-sha224 key data)  sha224?

  key : bytes?
  data : bytes?

procedure

(hmac-sha256 key data)  sha256?

  key : bytes?
  data : bytes?

procedure

(hmac-sha384 key data)  sha384?

  key : bytes?
  data : bytes?

procedure

(hmac-sha512 key data)  sha512?

  key : bytes?
  data : bytes?
HMAC-SHA encode key and data.

3 Hex string

procedure

(bytes->hex-string bstr)  string?

  bstr : bytes?
Convert bstr to a hexadecimal string represention.

4 Predicates for contracts

procedure

(sha1? x)  boolean?

  x : any/c
Is x a bytes? of length 20?

procedure

(sha224? x)  boolean?

  x : any/c
Is x a bytes? of length 28?

procedure

(sha256? x)  boolean?

  x : any/c
Is x a bytes? of length 32?

procedure

(sha384? x)  boolean?

  x : any/c
Is x a bytes? of length 48?

procedure

(sha512? x)  boolean?

  x : any/c
Is x a bytes? of length 64?