module RbNaCl::Hash
def self.blake2b(data, options = {})
-
(String)- The Blake2b hash digest as raw bytes
Raises:
-
(CryptoError)- If the hashing fails for some reason.
Options Hash:
(**options)-
personal(Personal) -- Provide personalisation string to allow pinning a hash for a particular purpose. -
salt(String) -- Provide a salt to support randomised hashing. -
key(String) -- 64-byte (or less) key for keyed mode -
digest_size(Fixnum) -- Size in bytes (1-64, default 64)
Parameters:
-
data(String) -- The data, as a collection of bytes
def self.blake2b(data, options = {}) Blake2b.digest(data, options) end
def self.sha256(data)
-
(String)- The SHA-256 hash digest as raw bytes
Raises:
-
(CryptoError)- If the hashing fails for some reason.
Parameters:
-
data(#to_str) -- The data, as a collection of bytes
def self.sha256(data) data = data.to_str digest = Util.zeros(SHA256::BYTES) SHA256.hash_sha256(digest, data, data.bytesize) || raise(CryptoError, "Hashing failed!") digest end
def self.sha512(data)
-
(String)- The SHA-512 hash digest as raw bytes
Raises:
-
(CryptoError)- If the hashing fails for some reason.
Parameters:
-
data(#to_str) -- The data, as a collection of bytes
def self.sha512(data) digest = Util.zeros(SHA512::BYTES) SHA512.hash_sha512(digest, data, data.bytesize) || raise(CryptoError, "Hashing failed!") digest end