Skip to content

Commit

Permalink
Encoding support for Blake2b#hash
Browse files Browse the repository at this point in the history
  • Loading branch information
tarcieri committed Jun 25, 2013
1 parent 8738db4 commit 4fd18d9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/rbnacl/hash/blake2b.rb
Expand Up @@ -31,12 +31,13 @@ def initialize(opts = {})
# Calculate a Blake2b hash
#
# @param [String] message Message to be hashed
# @param [#to_sym] encoding Encoding of the returned hash
#
# @return [String] Blake2b digest of the string as raw bytes
def hash(message)
def hash(message, encoding = :raw)
digest = Util.zeros(@digest_size)
NaCl.crypto_hash_blake2b(digest, @digest_size, message, message.bytesize, @key, @key_size) || raise(CryptoError, "Hashing failed!")
digest
Encoder[encoding].encode(digest)
end
end
end
Expand Down

0 comments on commit 4fd18d9

Please sign in to comment.