Sha256: d0259b00246a9bc1135f7cd48010897c54695a4d56f8e33ec18f30c7aa6fa128
Contents?: true
Size: 747 Bytes
Versions: 3
Compression:
Stored size: 747 Bytes
Contents
require 'rbnacl/libsodium' require 'cryptor/symmetric_encryption/cipher' module Cryptor class SymmetricEncryption module Ciphers # XSalsa20+Poly1305 authenticated stream cipher class XSalsa20Poly1305 < Cipher register :xsalsa20poly1305, key_bytes: RbNaCl::SecretBoxes::XSalsa20Poly1305.key_bytes def encrypt(key, plaintext) box(key).encrypt(plaintext) end def decrypt(key, ciphertext) box(key).decrypt(ciphertext) rescue RbNaCl::CryptoError => ex raise CorruptedMessageError, ex.to_s end private def box(key) RbNaCl::SimpleBox.new(RbNaCl::SecretBoxes::XSalsa20Poly1305.new(key)) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems