Fixed some typos in proc names

This commit is contained in:
zhibog
2021-10-16 19:20:43 +02:00
parent b7a0627d09
commit dd7449b8b5
6 changed files with 62 additions and 62 deletions
+5 -5
View File
@@ -71,21 +71,21 @@ hash_string :: proc(data: string) -> [64]byte {
// hash_bytes will hash the given input and return the // hash_bytes will hash the given input and return the
// computed hash // computed hash
hash_bytes :: proc(data: []byte) -> [64]byte { hash_bytes :: proc(data: []byte) -> [64]byte {
_create_blake2_ctx() _create_blake2b_ctx()
return _hash_impl->hash_bytes_64(data) return _hash_impl->hash_bytes_64(data)
} }
// hash_stream will read the stream in chunks and compute a // hash_stream will read the stream in chunks and compute a
// hash from its contents // hash from its contents
hash_stream :: proc(s: io.Stream) -> ([64]byte, bool) { hash_stream :: proc(s: io.Stream) -> ([64]byte, bool) {
_create_blake2_ctx() _create_blake2b_ctx()
return _hash_impl->hash_stream_64(s) return _hash_impl->hash_stream_64(s)
} }
// hash_file will read the file provided by the given handle // hash_file will read the file provided by the given handle
// and compute a hash // and compute a hash
hash_file :: proc(hd: os.Handle, load_at_once := false) -> ([64]byte, bool) { hash_file :: proc(hd: os.Handle, load_at_once := false) -> ([64]byte, bool) {
_create_blake2_ctx() _create_blake2b_ctx()
return _hash_impl->hash_file_64(hd, load_at_once) return _hash_impl->hash_file_64(hd, load_at_once)
} }
@@ -154,7 +154,7 @@ hash_file_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle, loa
} }
@(private) @(private)
_create_blake2_ctx :: #force_inline proc() { _create_blake2b_ctx :: #force_inline proc() {
ctx: _blake2.Blake2b_Context ctx: _blake2.Blake2b_Context
cfg: _blake2.Blake2_Config cfg: _blake2.Blake2_Config
cfg.size = _blake2.BLAKE2B_SIZE cfg.size = _blake2.BLAKE2B_SIZE
@@ -165,7 +165,7 @@ _create_blake2_ctx :: #force_inline proc() {
@(private) @(private)
_init_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context) { _init_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context) {
_create_blake2_ctx() _create_blake2b_ctx()
if c, ok := ctx.internal_ctx.(_blake2.Blake2b_Context); ok { if c, ok := ctx.internal_ctx.(_blake2.Blake2b_Context); ok {
_blake2.init_odin(&c) _blake2.init_odin(&c)
} }
+5 -5
View File
@@ -71,21 +71,21 @@ hash_string :: proc(data: string) -> [32]byte {
// hash_bytes will hash the given input and return the // hash_bytes will hash the given input and return the
// computed hash // computed hash
hash_bytes :: proc(data: []byte) -> [32]byte { hash_bytes :: proc(data: []byte) -> [32]byte {
_create_blake2_ctx() _create_blake2s_ctx()
return _hash_impl->hash_bytes_32(data) return _hash_impl->hash_bytes_32(data)
} }
// hash_stream will read the stream in chunks and compute a // hash_stream will read the stream in chunks and compute a
// hash from its contents // hash from its contents
hash_stream :: proc(s: io.Stream) -> ([32]byte, bool) { hash_stream :: proc(s: io.Stream) -> ([32]byte, bool) {
_create_blake2_ctx() _create_blake2s_ctx()
return _hash_impl->hash_stream_32(s) return _hash_impl->hash_stream_32(s)
} }
// hash_file will read the file provided by the given handle // hash_file will read the file provided by the given handle
// and compute a hash // and compute a hash
hash_file :: proc(hd: os.Handle, load_at_once := false) -> ([32]byte, bool) { hash_file :: proc(hd: os.Handle, load_at_once := false) -> ([32]byte, bool) {
_create_blake2_ctx() _create_blake2s_ctx()
return _hash_impl->hash_file_32(hd, load_at_once) return _hash_impl->hash_file_32(hd, load_at_once)
} }
@@ -154,7 +154,7 @@ hash_file_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle, loa
} }
@(private) @(private)
_create_blake2_ctx :: #force_inline proc() { _create_blake2s_ctx :: #force_inline proc() {
ctx: _blake2.Blake2s_Context ctx: _blake2.Blake2s_Context
cfg: _blake2.Blake2_Config cfg: _blake2.Blake2_Config
cfg.size = _blake2.BLAKE2S_SIZE cfg.size = _blake2.BLAKE2S_SIZE
@@ -165,7 +165,7 @@ _create_blake2_ctx :: #force_inline proc() {
@(private) @(private)
_init_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context) { _init_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context) {
_create_blake2_ctx() _create_blake2s_ctx()
if c, ok := ctx.internal_ctx.(_blake2.Blake2s_Context); ok { if c, ok := ctx.internal_ctx.(_blake2.Blake2s_Context); ok {
_blake2.init_odin(&c) _blake2.init_odin(&c)
} }
+17 -17
View File
@@ -80,21 +80,21 @@ hash_string_224 :: proc(data: string) -> [28]byte {
// hash_bytes_224 will hash the given input and return the // hash_bytes_224 will hash the given input and return the
// computed hash // computed hash
hash_bytes_224 :: proc(data: []byte) -> [28]byte { hash_bytes_224 :: proc(data: []byte) -> [28]byte {
_create_sha3_ctx(28) _create_keccak_ctx(28)
return _hash_impl->hash_bytes_28(data) return _hash_impl->hash_bytes_28(data)
} }
// hash_stream_224 will read the stream in chunks and compute a // hash_stream_224 will read the stream in chunks and compute a
// hash from its contents // hash from its contents
hash_stream_224 :: proc(s: io.Stream) -> ([28]byte, bool) { hash_stream_224 :: proc(s: io.Stream) -> ([28]byte, bool) {
_create_sha3_ctx(28) _create_keccak_ctx(28)
return _hash_impl->hash_stream_28(s) return _hash_impl->hash_stream_28(s)
} }
// hash_file_224 will read the file provided by the given handle // hash_file_224 will read the file provided by the given handle
// and compute a hash // and compute a hash
hash_file_224 :: proc(hd: os.Handle, load_at_once := false) -> ([28]byte, bool) { hash_file_224 :: proc(hd: os.Handle, load_at_once := false) -> ([28]byte, bool) {
_create_sha3_ctx(28) _create_keccak_ctx(28)
return _hash_impl->hash_file_28(hd, load_at_once) return _hash_impl->hash_file_28(hd, load_at_once)
} }
@@ -114,21 +114,21 @@ hash_string_256 :: proc(data: string) -> [32]byte {
// hash_bytes_256 will hash the given input and return the // hash_bytes_256 will hash the given input and return the
// computed hash // computed hash
hash_bytes_256 :: proc(data: []byte) -> [32]byte { hash_bytes_256 :: proc(data: []byte) -> [32]byte {
_create_sha3_ctx(32) _create_keccak_ctx(32)
return _hash_impl->hash_bytes_32(data) return _hash_impl->hash_bytes_32(data)
} }
// hash_stream_256 will read the stream in chunks and compute a // hash_stream_256 will read the stream in chunks and compute a
// hash from its contents // hash from its contents
hash_stream_256 :: proc(s: io.Stream) -> ([32]byte, bool) { hash_stream_256 :: proc(s: io.Stream) -> ([32]byte, bool) {
_create_sha3_ctx(32) _create_keccak_ctx(32)
return _hash_impl->hash_stream_32(s) return _hash_impl->hash_stream_32(s)
} }
// hash_file_256 will read the file provided by the given handle // hash_file_256 will read the file provided by the given handle
// and compute a hash // and compute a hash
hash_file_256 :: proc(hd: os.Handle, load_at_once := false) -> ([32]byte, bool) { hash_file_256 :: proc(hd: os.Handle, load_at_once := false) -> ([32]byte, bool) {
_create_sha3_ctx(32) _create_keccak_ctx(32)
return _hash_impl->hash_file_32(hd, load_at_once) return _hash_impl->hash_file_32(hd, load_at_once)
} }
@@ -148,21 +148,21 @@ hash_string_384 :: proc(data: string) -> [48]byte {
// hash_bytes_384 will hash the given input and return the // hash_bytes_384 will hash the given input and return the
// computed hash // computed hash
hash_bytes_384 :: proc(data: []byte) -> [48]byte { hash_bytes_384 :: proc(data: []byte) -> [48]byte {
_create_sha3_ctx(48) _create_keccak_ctx(48)
return _hash_impl->hash_bytes_48(data) return _hash_impl->hash_bytes_48(data)
} }
// hash_stream_384 will read the stream in chunks and compute a // hash_stream_384 will read the stream in chunks and compute a
// hash from its contents // hash from its contents
hash_stream_384 :: proc(s: io.Stream) -> ([48]byte, bool) { hash_stream_384 :: proc(s: io.Stream) -> ([48]byte, bool) {
_create_sha3_ctx(48) _create_keccak_ctx(48)
return _hash_impl->hash_stream_48(s) return _hash_impl->hash_stream_48(s)
} }
// hash_file_384 will read the file provided by the given handle // hash_file_384 will read the file provided by the given handle
// and compute a hash // and compute a hash
hash_file_384 :: proc(hd: os.Handle, load_at_once := false) -> ([48]byte, bool) { hash_file_384 :: proc(hd: os.Handle, load_at_once := false) -> ([48]byte, bool) {
_create_sha3_ctx(48) _create_keccak_ctx(48)
return _hash_impl->hash_file_48(hd, load_at_once) return _hash_impl->hash_file_48(hd, load_at_once)
} }
@@ -182,21 +182,21 @@ hash_string_512 :: proc(data: string) -> [64]byte {
// hash_bytes_512 will hash the given input and return the // hash_bytes_512 will hash the given input and return the
// computed hash // computed hash
hash_bytes_512 :: proc(data: []byte) -> [64]byte { hash_bytes_512 :: proc(data: []byte) -> [64]byte {
_create_sha3_ctx(64) _create_keccak_ctx(64)
return _hash_impl->hash_bytes_64(data) return _hash_impl->hash_bytes_64(data)
} }
// hash_stream_512 will read the stream in chunks and compute a // hash_stream_512 will read the stream in chunks and compute a
// hash from its contents // hash from its contents
hash_stream_512 :: proc(s: io.Stream) -> ([64]byte, bool) { hash_stream_512 :: proc(s: io.Stream) -> ([64]byte, bool) {
_create_sha3_ctx(64) _create_keccak_ctx(64)
return _hash_impl->hash_stream_64(s) return _hash_impl->hash_stream_64(s)
} }
// hash_file_512 will read the file provided by the given handle // hash_file_512 will read the file provided by the given handle
// and compute a hash // and compute a hash
hash_file_512 :: proc(hd: os.Handle, load_at_once := false) -> ([64]byte, bool) { hash_file_512 :: proc(hd: os.Handle, load_at_once := false) -> ([64]byte, bool) {
_create_sha3_ctx(64) _create_keccak_ctx(64)
return _hash_impl->hash_file_64(hd, load_at_once) return _hash_impl->hash_file_64(hd, load_at_once)
} }
@@ -388,7 +388,7 @@ hash_file_odin_64 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
} }
@(private) @(private)
_create_sha3_ctx :: #force_inline proc(mdlen: int) { _create_keccak_ctx :: #force_inline proc(mdlen: int) {
ctx: _sha3.Sha3_Context ctx: _sha3.Sha3_Context
ctx.mdlen = mdlen ctx.mdlen = mdlen
ctx.is_keccak = true ctx.is_keccak = true
@@ -404,10 +404,10 @@ _create_sha3_ctx :: #force_inline proc(mdlen: int) {
@(private) @(private)
_init_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context) { _init_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context) {
#partial switch ctx.hash_size { #partial switch ctx.hash_size {
case ._28: _create_sha3_ctx(28) case ._28: _create_keccak_ctx(28)
case ._32: _create_sha3_ctx(32) case ._32: _create_keccak_ctx(32)
case ._48: _create_sha3_ctx(48) case ._48: _create_keccak_ctx(48)
case ._64: _create_sha3_ctx(64) case ._64: _create_keccak_ctx(64)
} }
if c, ok := ctx.internal_ctx.(_sha3.Sha3_Context); ok { if c, ok := ctx.internal_ctx.(_sha3.Sha3_Context); ok {
_sha3.init_odin(&c) _sha3.init_odin(&c)
+9 -9
View File
@@ -74,21 +74,21 @@ hash_string_128 :: proc(data: string) -> [16]byte {
// hash_bytes_128 will hash the given input and return the // hash_bytes_128 will hash the given input and return the
// computed hash // computed hash
hash_bytes_128 :: proc(data: []byte) -> [16]byte { hash_bytes_128 :: proc(data: []byte) -> [16]byte {
_create_sha3_ctx(16) _create_shake_ctx(16)
return _hash_impl->hash_bytes_16(data) return _hash_impl->hash_bytes_16(data)
} }
// hash_stream_128 will read the stream in chunks and compute a // hash_stream_128 will read the stream in chunks and compute a
// hash from its contents // hash from its contents
hash_stream_128 :: proc(s: io.Stream) -> ([16]byte, bool) { hash_stream_128 :: proc(s: io.Stream) -> ([16]byte, bool) {
_create_sha3_ctx(16) _create_shake_ctx(16)
return _hash_impl->hash_stream_16(s) return _hash_impl->hash_stream_16(s)
} }
// hash_file_128 will read the file provided by the given handle // hash_file_128 will read the file provided by the given handle
// and compute a hash // and compute a hash
hash_file_128 :: proc(hd: os.Handle, load_at_once := false) -> ([16]byte, bool) { hash_file_128 :: proc(hd: os.Handle, load_at_once := false) -> ([16]byte, bool) {
_create_sha3_ctx(16) _create_shake_ctx(16)
return _hash_impl->hash_file_16(hd, load_at_once) return _hash_impl->hash_file_16(hd, load_at_once)
} }
@@ -108,21 +108,21 @@ hash_string_256 :: proc(data: string) -> [32]byte {
// hash_bytes_256 will hash the given input and return the // hash_bytes_256 will hash the given input and return the
// computed hash // computed hash
hash_bytes_256 :: proc(data: []byte) -> [32]byte { hash_bytes_256 :: proc(data: []byte) -> [32]byte {
_create_sha3_ctx(32) _create_shake_ctx(32)
return _hash_impl->hash_bytes_32(data) return _hash_impl->hash_bytes_32(data)
} }
// hash_stream_256 will read the stream in chunks and compute a // hash_stream_256 will read the stream in chunks and compute a
// hash from its contents // hash from its contents
hash_stream_256 :: proc(s: io.Stream) -> ([32]byte, bool) { hash_stream_256 :: proc(s: io.Stream) -> ([32]byte, bool) {
_create_sha3_ctx(32) _create_shake_ctx(32)
return _hash_impl->hash_stream_32(s) return _hash_impl->hash_stream_32(s)
} }
// hash_file_256 will read the file provided by the given handle // hash_file_256 will read the file provided by the given handle
// and compute a hash // and compute a hash
hash_file_256 :: proc(hd: os.Handle, load_at_once := false) -> ([32]byte, bool) { hash_file_256 :: proc(hd: os.Handle, load_at_once := false) -> ([32]byte, bool) {
_create_sha3_ctx(32) _create_shake_ctx(32)
return _hash_impl->hash_file_32(hd, load_at_once) return _hash_impl->hash_file_32(hd, load_at_once)
} }
@@ -236,7 +236,7 @@ hash_file_odin_32 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
} }
@(private) @(private)
_create_sha3_ctx :: #force_inline proc(mdlen: int) { _create_shake_ctx :: #force_inline proc(mdlen: int) {
ctx: _sha3.Sha3_Context ctx: _sha3.Sha3_Context
ctx.mdlen = mdlen ctx.mdlen = mdlen
_hash_impl.internal_ctx = ctx _hash_impl.internal_ctx = ctx
@@ -249,8 +249,8 @@ _create_sha3_ctx :: #force_inline proc(mdlen: int) {
@(private) @(private)
_init_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context) { _init_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context) {
#partial switch ctx.hash_size { #partial switch ctx.hash_size {
case ._16: _create_sha3_ctx(16) case ._16: _create_shake_ctx(16)
case ._32: _create_sha3_ctx(32) case ._32: _create_shake_ctx(32)
} }
if c, ok := ctx.internal_ctx.(_sha3.Sha3_Context); ok { if c, ok := ctx.internal_ctx.(_sha3.Sha3_Context); ok {
_sha3.init_odin(&c) _sha3.init_odin(&c)
+13 -13
View File
@@ -76,21 +76,21 @@ hash_string_128 :: proc(data: string) -> [16]byte {
// hash_bytes_128 will hash the given input and return the // hash_bytes_128 will hash the given input and return the
// computed hash // computed hash
hash_bytes_128 :: proc(data: []byte) -> [16]byte { hash_bytes_128 :: proc(data: []byte) -> [16]byte {
_create_ripemd_ctx(16) _create_tiger_ctx(16)
return _hash_impl->hash_bytes_16(data) return _hash_impl->hash_bytes_16(data)
} }
// hash_stream_128 will read the stream in chunks and compute a // hash_stream_128 will read the stream in chunks and compute a
// hash from its contents // hash from its contents
hash_stream_128 :: proc(s: io.Stream) -> ([16]byte, bool) { hash_stream_128 :: proc(s: io.Stream) -> ([16]byte, bool) {
_create_ripemd_ctx(16) _create_tiger_ctx(16)
return _hash_impl->hash_stream_16(s) return _hash_impl->hash_stream_16(s)
} }
// hash_file_128 will read the file provided by the given handle // hash_file_128 will read the file provided by the given handle
// and compute a hash // and compute a hash
hash_file_128 :: proc(hd: os.Handle, load_at_once := false) -> ([16]byte, bool) { hash_file_128 :: proc(hd: os.Handle, load_at_once := false) -> ([16]byte, bool) {
_create_ripemd_ctx(16) _create_tiger_ctx(16)
return _hash_impl->hash_file_16(hd, load_at_once) return _hash_impl->hash_file_16(hd, load_at_once)
} }
@@ -110,21 +110,21 @@ hash_string_160 :: proc(data: string) -> [20]byte {
// hash_bytes_160 will hash the given input and return the // hash_bytes_160 will hash the given input and return the
// computed hash // computed hash
hash_bytes_160 :: proc(data: []byte) -> [20]byte { hash_bytes_160 :: proc(data: []byte) -> [20]byte {
_create_ripemd_ctx(20) _create_tiger_ctx(20)
return _hash_impl->hash_bytes_20(data) return _hash_impl->hash_bytes_20(data)
} }
// hash_stream_160 will read the stream in chunks and compute a // hash_stream_160 will read the stream in chunks and compute a
// hash from its contents // hash from its contents
hash_stream_160 :: proc(s: io.Stream) -> ([20]byte, bool) { hash_stream_160 :: proc(s: io.Stream) -> ([20]byte, bool) {
_create_ripemd_ctx(20) _create_tiger_ctx(20)
return _hash_impl->hash_stream_20(s) return _hash_impl->hash_stream_20(s)
} }
// hash_file_160 will read the file provided by the given handle // hash_file_160 will read the file provided by the given handle
// and compute a hash // and compute a hash
hash_file_160 :: proc(hd: os.Handle, load_at_once := false) -> ([20]byte, bool) { hash_file_160 :: proc(hd: os.Handle, load_at_once := false) -> ([20]byte, bool) {
_create_ripemd_ctx(20) _create_tiger_ctx(20)
return _hash_impl->hash_file_20(hd, load_at_once) return _hash_impl->hash_file_20(hd, load_at_once)
} }
@@ -144,21 +144,21 @@ hash_string_192 :: proc(data: string) -> [24]byte {
// hash_bytes_192 will hash the given input and return the // hash_bytes_192 will hash the given input and return the
// computed hash // computed hash
hash_bytes_192 :: proc(data: []byte) -> [24]byte { hash_bytes_192 :: proc(data: []byte) -> [24]byte {
_create_ripemd_ctx(24) _create_tiger_ctx(24)
return _hash_impl->hash_bytes_24(data) return _hash_impl->hash_bytes_24(data)
} }
// hash_stream_192 will read the stream in chunks and compute a // hash_stream_192 will read the stream in chunks and compute a
// hash from its contents // hash from its contents
hash_stream_192 :: proc(s: io.Stream) -> ([24]byte, bool) { hash_stream_192 :: proc(s: io.Stream) -> ([24]byte, bool) {
_create_ripemd_ctx(24) _create_tiger_ctx(24)
return _hash_impl->hash_stream_24(s) return _hash_impl->hash_stream_24(s)
} }
// hash_file_192 will read the file provided by the given handle // hash_file_192 will read the file provided by the given handle
// and compute a hash // and compute a hash
hash_file_192 :: proc(hd: os.Handle, load_at_once := false) -> ([24]byte, bool) { hash_file_192 :: proc(hd: os.Handle, load_at_once := false) -> ([24]byte, bool) {
_create_ripemd_ctx(24) _create_tiger_ctx(24)
return _hash_impl->hash_file_24(hd, load_at_once) return _hash_impl->hash_file_24(hd, load_at_once)
} }
@@ -293,7 +293,7 @@ hash_file_odin_24 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
} }
@(private) @(private)
_create_ripemd_ctx :: #force_inline proc(hash_size: int) { _create_tiger_ctx :: #force_inline proc(hash_size: int) {
ctx: _tiger.Tiger_Context ctx: _tiger.Tiger_Context
ctx.ver = 1 ctx.ver = 1
_hash_impl.internal_ctx = ctx _hash_impl.internal_ctx = ctx
@@ -307,9 +307,9 @@ _create_ripemd_ctx :: #force_inline proc(hash_size: int) {
@(private) @(private)
_init_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context) { _init_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context) {
#partial switch ctx.hash_size { #partial switch ctx.hash_size {
case ._16: _create_ripemd_ctx(16) case ._16: _create_tiger_ctx(16)
case ._20: _create_ripemd_ctx(20) case ._20: _create_tiger_ctx(20)
case ._24: _create_ripemd_ctx(24) case ._24: _create_tiger_ctx(24)
} }
if c, ok := ctx.internal_ctx.(_tiger.Tiger_Context); ok { if c, ok := ctx.internal_ctx.(_tiger.Tiger_Context); ok {
_tiger.init_odin(&c) _tiger.init_odin(&c)
+13 -13
View File
@@ -76,21 +76,21 @@ hash_string_128 :: proc(data: string) -> [16]byte {
// hash_bytes_128 will hash the given input and return the // hash_bytes_128 will hash the given input and return the
// computed hash // computed hash
hash_bytes_128 :: proc(data: []byte) -> [16]byte { hash_bytes_128 :: proc(data: []byte) -> [16]byte {
_create_ripemd_ctx(16) _create_tiger2_ctx(16)
return _hash_impl->hash_bytes_16(data) return _hash_impl->hash_bytes_16(data)
} }
// hash_stream_128 will read the stream in chunks and compute a // hash_stream_128 will read the stream in chunks and compute a
// hash from its contents // hash from its contents
hash_stream_128 :: proc(s: io.Stream) -> ([16]byte, bool) { hash_stream_128 :: proc(s: io.Stream) -> ([16]byte, bool) {
_create_ripemd_ctx(16) _create_tiger2_ctx(16)
return _hash_impl->hash_stream_16(s) return _hash_impl->hash_stream_16(s)
} }
// hash_file_128 will read the file provided by the given handle // hash_file_128 will read the file provided by the given handle
// and compute a hash // and compute a hash
hash_file_128 :: proc(hd: os.Handle, load_at_once := false) -> ([16]byte, bool) { hash_file_128 :: proc(hd: os.Handle, load_at_once := false) -> ([16]byte, bool) {
_create_ripemd_ctx(16) _create_tiger2_ctx(16)
return _hash_impl->hash_file_16(hd, load_at_once) return _hash_impl->hash_file_16(hd, load_at_once)
} }
@@ -110,21 +110,21 @@ hash_string_160 :: proc(data: string) -> [20]byte {
// hash_bytes_160 will hash the given input and return the // hash_bytes_160 will hash the given input and return the
// computed hash // computed hash
hash_bytes_160 :: proc(data: []byte) -> [20]byte { hash_bytes_160 :: proc(data: []byte) -> [20]byte {
_create_ripemd_ctx(20) _create_tiger2_ctx(20)
return _hash_impl->hash_bytes_20(data) return _hash_impl->hash_bytes_20(data)
} }
// hash_stream_160 will read the stream in chunks and compute a // hash_stream_160 will read the stream in chunks and compute a
// hash from its contents // hash from its contents
hash_stream_160 :: proc(s: io.Stream) -> ([20]byte, bool) { hash_stream_160 :: proc(s: io.Stream) -> ([20]byte, bool) {
_create_ripemd_ctx(20) _create_tiger2_ctx(20)
return _hash_impl->hash_stream_20(s) return _hash_impl->hash_stream_20(s)
} }
// hash_file_160 will read the file provided by the given handle // hash_file_160 will read the file provided by the given handle
// and compute a hash // and compute a hash
hash_file_160 :: proc(hd: os.Handle, load_at_once := false) -> ([20]byte, bool) { hash_file_160 :: proc(hd: os.Handle, load_at_once := false) -> ([20]byte, bool) {
_create_ripemd_ctx(20) _create_tiger2_ctx(20)
return _hash_impl->hash_file_20(hd, load_at_once) return _hash_impl->hash_file_20(hd, load_at_once)
} }
@@ -144,21 +144,21 @@ hash_string_192 :: proc(data: string) -> [24]byte {
// hash_bytes_192 will hash the given input and return the // hash_bytes_192 will hash the given input and return the
// computed hash // computed hash
hash_bytes_192 :: proc(data: []byte) -> [24]byte { hash_bytes_192 :: proc(data: []byte) -> [24]byte {
_create_ripemd_ctx(24) _create_tiger2_ctx(24)
return _hash_impl->hash_bytes_24(data) return _hash_impl->hash_bytes_24(data)
} }
// hash_stream_192 will read the stream in chunks and compute a // hash_stream_192 will read the stream in chunks and compute a
// hash from its contents // hash from its contents
hash_stream_192 :: proc(s: io.Stream) -> ([24]byte, bool) { hash_stream_192 :: proc(s: io.Stream) -> ([24]byte, bool) {
_create_ripemd_ctx(24) _create_tiger2_ctx(24)
return _hash_impl->hash_stream_24(s) return _hash_impl->hash_stream_24(s)
} }
// hash_file_192 will read the file provided by the given handle // hash_file_192 will read the file provided by the given handle
// and compute a hash // and compute a hash
hash_file_192 :: proc(hd: os.Handle, load_at_once := false) -> ([24]byte, bool) { hash_file_192 :: proc(hd: os.Handle, load_at_once := false) -> ([24]byte, bool) {
_create_ripemd_ctx(24) _create_tiger2_ctx(24)
return _hash_impl->hash_file_24(hd, load_at_once) return _hash_impl->hash_file_24(hd, load_at_once)
} }
@@ -293,7 +293,7 @@ hash_file_odin_24 :: #force_inline proc(ctx: ^_ctx.Hash_Context, hd: os.Handle,
} }
@(private) @(private)
_create_ripemd_ctx :: #force_inline proc(hash_size: int) { _create_tiger2_ctx :: #force_inline proc(hash_size: int) {
ctx: _tiger.Tiger_Context ctx: _tiger.Tiger_Context
ctx.ver = 2 ctx.ver = 2
_hash_impl.internal_ctx = ctx _hash_impl.internal_ctx = ctx
@@ -307,9 +307,9 @@ _create_ripemd_ctx :: #force_inline proc(hash_size: int) {
@(private) @(private)
_init_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context) { _init_odin :: #force_inline proc(ctx: ^_ctx.Hash_Context) {
#partial switch ctx.hash_size { #partial switch ctx.hash_size {
case ._16: _create_ripemd_ctx(16) case ._16: _create_tiger2_ctx(16)
case ._20: _create_ripemd_ctx(20) case ._20: _create_tiger2_ctx(20)
case ._24: _create_ripemd_ctx(24) case ._24: _create_tiger2_ctx(24)
} }
if c, ok := ctx.internal_ctx.(_tiger.Tiger_Context); ok { if c, ok := ctx.internal_ctx.(_tiger.Tiger_Context); ok {
_tiger.init_odin(&c) _tiger.init_odin(&c)