Method: RbNaCl::SimpleBox#open

Defined in:
lib/rbnacl/simple_box.rb

#open(enciphered_message) ⇒ String Also known as: decrypt

Decrypts the ciphertext with a random nonce

Takes a ciphertext, optionally decodes it, then splits the nonce off the front and uses this to decrypt. Returns the message.

Raises:

  • (CryptoError)

    If the message has been tampered with.



97
98
99
100
# File 'lib/rbnacl/simple_box.rb', line 97

def open(enciphered_message)
  nonce, ciphertext = extract_nonce(enciphered_message.to_s)
  @box.open(nonce, ciphertext)
end