Class: Prototok::Ciphers::V1::EncryptedMac
- Defined in:
- lib/prototok/ciphers/V1/encrypted_mac.rb
Instance Method Summary collapse
- #decode(decoded_nonce, decoded_blob) ⇒ Object
- #encode(blob) ⇒ Object
-
#initialize(private_key) ⇒ EncryptedMac
constructor
A new instance of EncryptedMac.
Methods inherited from Base
Constructor Details
#initialize(private_key) ⇒ EncryptedMac
Returns a new instance of EncryptedMac.
9 10 11 |
# File 'lib/prototok/ciphers/V1/encrypted_mac.rb', line 9 def initialize(private_key) @cipher = cipher_class.new(private_key) end |
Instance Method Details
#decode(decoded_nonce, decoded_blob) ⇒ Object
18 19 20 |
# File 'lib/prototok/ciphers/V1/encrypted_mac.rb', line 18 def decode(decoded_nonce, decoded_blob) @cipher.open(decoded_nonce, decoded_blob) end |
#encode(blob) ⇒ Object
13 14 15 16 |
# File 'lib/prototok/ciphers/V1/encrypted_mac.rb', line 13 def encode(blob) nonce = RbNaCl::Random.random_bytes @cipher.nonce_bytes [nonce, @cipher.box(nonce, blob)] end |