Class: WSS4R::Security::Crypto::CryptHash
- Inherits:
-
Object
- Object
- WSS4R::Security::Crypto::CryptHash
- Defined in:
- lib/wss4r/security/crypto/hash.rb
Instance Method Summary collapse
- #digest(value) ⇒ Object
- #digest_b64(value) ⇒ Object
-
#initialize(type = "SHA1") ⇒ CryptHash
constructor
A new instance of CryptHash.
- #to_s ⇒ Object
Constructor Details
#initialize(type = "SHA1") ⇒ CryptHash
Returns a new instance of CryptHash.
12 13 14 15 |
# File 'lib/wss4r/security/crypto/hash.rb', line 12 def initialize(type = "SHA1") @digest = SHA1.new() if (type == "SHA1") @digest = MD5.new() if (type == "MD5") end |
Instance Method Details
#digest(value) ⇒ Object
17 18 19 20 |
# File 'lib/wss4r/security/crypto/hash.rb', line 17 def digest(value) @digest.update(value) return @digest.digest() end |
#digest_b64(value) ⇒ Object
22 23 24 25 |
# File 'lib/wss4r/security/crypto/hash.rb', line 22 def digest_b64(value) digest = self.digest(value) return Base64.encode64(digest) end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/wss4r/security/crypto/hash.rb', line 27 def to_s() return @digest.to_s() end |