Returns a digest of 20 bytes as a CString, note that all the characters are not necessarily ASCII. If you want the hex string version of the digest, use sha1_hexdigest.
import base64
assert "The quick brown fox jumps over the lazy dog".sha1 == [0x2F, 0xD4, 0xE1, 0xC6, 0x7A, 0x2D, 0x28, 0xFC, 0xED, 0x84, 0x9E, 0xE1, 0xBB, 0x76, 0xE7, 0x39, 0x1B, 0x93, 0xEB, 0x12]
# Computes the SHA1 of the receiver
#
# Returns a digest of 20 bytes as a CString,
# note that all the characters are not necessarily ASCII.
# If you want the hex string version of the digest, use
# sha1_hexdigest.
#
# import base64
# assert "The quick brown fox jumps over the lazy dog".sha1 == [0x2F, 0xD4, 0xE1, 0xC6, 0x7A, 0x2D, 0x28, 0xFC, 0xED, 0x84, 0x9E, 0xE1, 0xBB, 0x76, 0xE7, 0x39, 0x1B, 0x93, 0xEB, 0x12]
fun sha1: Bytes do
return new Bytes(to_cstring.sha1_intern(byte_length), 20, 20)
end
lib/sha1/sha1.nit:240,2--251,4