class CryptoToolchain::BlackBoxes::SHA1Mac
Attributes
key[R]
Public Class Methods
new(key: Random.new.bytes(16))
click to toggle source
# File lib/crypto_toolchain/black_boxes/sha1_mac.rb, line 6 def initialize(key: Random.new.bytes(16)) @key = key end
Public Instance Methods
mac(str)
click to toggle source
# File lib/crypto_toolchain/black_boxes/sha1_mac.rb, line 10 def mac(str) concat = key + str CryptoToolchain::Utilities::SHA1.hexdigest(concat) end
valid?(message: , mac: )
click to toggle source
# File lib/crypto_toolchain/black_boxes/sha1_mac.rb, line 15 def valid?(message: , mac: ) self.mac(message) == mac end