Class: Cryptor::SymmetricEncryption::Ciphers::XSalsa20Poly1305

Inherits:
Cryptor::SymmetricEncryption::Cipher show all
Defined in:
lib/cryptor/symmetric_encryption/ciphers/xsalsa20poly1305.rb

Overview

XSalsa20+Poly1305 authenticated stream cipher

Constant Summary

Constants inherited from Cryptor::SymmetricEncryption::Cipher

Cryptor::SymmetricEncryption::Cipher::REGISTRY

Instance Attribute Summary

Attributes inherited from Cryptor::SymmetricEncryption::Cipher

#algorithm, #key_bytes

Instance Method Summary collapse

Methods inherited from Cryptor::SymmetricEncryption::Cipher

[], #initialize, #random_key, register

Constructor Details

This class inherits a constructor from Cryptor::SymmetricEncryption::Cipher

Instance Method Details

#decrypt(key, ciphertext) ⇒ Object



16
17
18
19
20
# File 'lib/cryptor/symmetric_encryption/ciphers/xsalsa20poly1305.rb', line 16

def decrypt(key, ciphertext)
  box(key).decrypt(ciphertext)
rescue RbNaCl::CryptoError => ex
  raise CorruptedMessageError, ex.to_s
end

#encrypt(key, plaintext) ⇒ Object



12
13
14
# File 'lib/cryptor/symmetric_encryption/ciphers/xsalsa20poly1305.rb', line 12

def encrypt(key, plaintext)
  box(key).encrypt(plaintext)
end