SHA-1
SHA-1 or SHA1 is a message digest algorithm; it transforms a message into a 160-bit hash. SHA-1 often appears in security protocols; for example, many HTTPS websites use RSA with SHA-1 to secure their connections. BitTorrent uses SHA-1 to verify downloads. Git and Mercurial use SHA-1 digests to identify commits.
A US government standard, FIPS 180-1, defines SHA-1.
- Warning: SHA-1 has known weaknesses. Users may consider a stronger alternative, such as SHA-256 (from the SHA-2 family) or the upcoming SHA-3.
Find the SHA-1 message digest for a string of octets. You may either call a SHA-1 library, or implement SHA-1 in your language. Both approaches interest Rosetta Code.
Factor
Factor provides sha1 in the checksums.sha vocabulary. In Factor, checksum-bytes returns a sequence of bytes; hex-string converts this sequence to a hexadecimal string.
IN: scratchpad USING: checksums checksums.sha ; IN: scratchpad "Rosetta Code" sha1 checksum-bytes hex-string . "48c98f7e5a6e736d790ab740dfc3f51a61abe2b5"
The implementation is at basis/checksums/sha/sha.factor.