-
-
Save Papierkorb/8a0dfcff272b77c75de52f218c49a765 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "openssl/lib_crypto" | |
lib LibCrypto | |
fun sha256 = SHA256(data : Char*, length : SizeT, md : Char*) : Char* | |
end | |
class OpenSSL::SHA256 | |
def self.hash(data : Bytes) | |
hash(data.to_unsafe, LibC::SizeT.new(data.bytesize)) | |
end | |
def self.hash(data : UInt8*, bytesize : LibC::SizeT) | |
buffer = uninitialized UInt8[32] | |
LibCrypto.sha256(data, bytesize, buffer) | |
buffer | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment