module Veronica
Constants
- VALID_SHA2_BIT_LENGTHS
- VALID_SHA2_ENCODING_FORMATS
- VERSION
Public Class Methods
generate_sha2(digest_bits: , string: , encoding_format: "hexdigest")
click to toggle source
We use hexdigest by default for familiarities sake
# File lib/veronica.rb, line 9 def self.generate_sha2(digest_bits: , string: , encoding_format: "hexdigest") unless VALID_SHA2_BIT_LENGTHS.include?(digest_bits) raise ArgumentError, "You can only use 256, 384, or 512 for bit length." end unless VALID_SHA2_ENCODING_FORMATS.include?(encoding_format) raise ArgumentError, "You can only use hexdigest, base64digest or just digest for an encoding format." end # This lets us dynamically pass in digest_bits as well as encoding formats to the Digest class. Digest::SHA2.new(digest_bits).method(encoding_format.to_sym).(string) end