std/digest/sha1
std/digest/src/sha1.trb
Sha1, the SHA-1 of FIPS 180-4 (RFC 3174): mysql_native_password, MongoDB's SCRAM-SHA-1 and the WebSocket
handshake's accept key still ask for it, but nothing new should choose it over Sha256 - collisions are practical
(SHAttered, 2017), which is why nothing here signs with it.
Ordinary TorbScript with no native, the same shape as Sha256: fed at once or in pieces, every word kept below
2^32 by a mask, the same bytes in both back ends.
type Sha1
type Sha1 with Hasher
SHA-1, fed in pieces: Sha1.add takes the next bytes and Sha1.finished answers the digest of everything added so
far without changing the hasher, so a hasher can be read, fed more, and read again.
Examples
print Sha1.of("abc".bytes()).hex()
// prints a9993e364706816aba3e25717850c26c9cd0d89
fn empty
static fn empty(): Self
A hasher with nothing fed yet, the same as Self().
fn of
static fn of(bytes: Bytes): Digest
The digest of bytes in one call.
fn blockSize
static fn blockSize(): Int
64: SHA-1 works in blocks of sixteen 32-bit words.
fn digestLength
static fn digestLength(): Int
20: a SHA-1 digest is 160 bits.
fn add
var fn add(bytes: Bytes)
Feeds the next bytes.
fn finished
fn finished(): Digest
The digest of everything added so far. The hasher itself is unchanged and may be fed more.