You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classDigest""" Produces a hash from the chunks of input. Feed the input with append() and produce a final hash from the concatenation of the input with final()."""let _digest_size: USizelet _ctx: Pointer[_EVPCTX]
var _hash: (Array[U8] val | None) = Nonenewmd4() =>
""" Use the MD4 algorithm to calculate the hash."""
_digest_size = 16ifdef"openssl_1.1.x"then
_ctx = @EVP_MD_CTX_new[Pointer[_EVPCTX]]()
else
_ctx = @EVP_MD_CTX_create[Pointer[_EVPCTX]]()
end
@EVP_DigestInit_ex[None](_ctx, @EVP_md4[Pointer[_EVPMD]](), USize(0))
newmd5() =>
""" Use the MD5 algorithm to calculate the hash."""
_digest_size = 16ifdef"openssl_1.1.x"then
_ctx = @EVP_MD_CTX_new[Pointer[_EVPCTX]]()
else
_ctx = @EVP_MD_CTX_create[Pointer[_EVPCTX]]()
end
@EVP_DigestInit_ex[None](_ctx, @EVP_md5[Pointer[_EVPMD]](), USize(0))
newripemd160() =>
""" Use the RIPEMD160 algorithm to calculate the hash."""
_digest_size = 20ifdef"openssl_1.1.x"then
_ctx = @EVP_MD_CTX_new[Pointer[_EVPCTX]]()
else
_ctx = @EVP_MD_CTX_create[Pointer[_EVPCTX]]()
end
@EVP_DigestInit_ex[None](_ctx, @EVP_ripemd160[Pointer[_EVPMD]](), USize(0))
At moment, the ffi methods are spread throughout the entire library. For clean and maintainable code, we can refer to the practice of lori:
https://github.com/seantallen-org/lori/blob/master/lori/pony_asio.pony
In the end it should look like this: