forked from AbleOS/ableos
27 lines
842 B
Plaintext
27 lines
842 B
Plaintext
.{hashers, log, memory, fmt, string, math} := @use("stn")
|
|
|
|
test := fn(): uint {
|
|
target := "abcdefghijklmnop"
|
|
strings := .["abcdefshijklmnop", "abcdefghijklnnop", "abcdefshijklmnop", "abcdefghijklmnop", "abcdefghijflmnop", "dbcdefghijklmnop", "abcdefghijklmnop"]
|
|
len := @sizeof(@TypeOf(strings)) / @sizeof([]u8)
|
|
|
|
// hasher := hashers.foldhash.FoldHasher.new(1)
|
|
hasher := hashers.foldhash.FoldHasher.default()
|
|
hasher.write(target.ptr, target.len)
|
|
correct := hasher.finish()
|
|
|
|
log.printf("target string: {}, target hash: {}", .(target, correct), .{radix: 16})
|
|
|
|
i := 0
|
|
loop if i == len break else {
|
|
defer i += 1
|
|
|
|
hasher.reset()
|
|
hasher.write(strings[i].ptr, strings[i].len)
|
|
d := hasher.finish()
|
|
log.printf("matches: {}, string: {}, hash: {}", .(d == correct, strings[i], d), .{radix: 16})
|
|
}
|
|
log.print("done", .{})
|
|
return 0
|
|
}
|