File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -124,7 +124,7 @@ fn (mut d Digest) write(p_ []byte) ?int {
124124 }
125125}
126126
127- fn (d &Digest) sum (b_in []byte ) []byte {
127+ pub fn (d &Digest) sum (b_in []byte ) []byte {
128128 // Make a copy of d so that caller can keep writing and summing.
129129 mut d0 := * d
130130 hash := d0 .checksum ()
Original file line number Diff line number Diff line change @@ -8,3 +8,12 @@ fn test_crypto_sha256() {
88 assert sha256 .sum ('This is a sha256 checksum.' .bytes ()).hex () ==
99 'dc7163299659529eae29683eb1ffec50d6c8fc7275ecb10c145fde0e125b8727'
1010}
11+
12+ fn test_crypto_sha256_writer () {
13+ mut digest := sha256 .new ()
14+ digest.write ('This is a' .bytes ()) or { assert false }
15+ digest.write (' sha256 checksum.' .bytes ()) or { assert false }
16+ sum := digest.sum ([])
17+ assert sum.hex () ==
18+ 'dc7163299659529eae29683eb1ffec50d6c8fc7275ecb10c145fde0e125b8727'
19+ }
You can’t perform that action at this time.
0 commit comments