class RbNaCl::Boxes::Sealed
def open(ciphertext)
-
(String)
- The decrypted message (BINARY encoded)
Raises:
-
(RbNaCl::CryptoError)
- If the ciphertext cannot be authenticated. -
(RbNaCl::CryptoError)
- If no private key is available.
Parameters:
-
ciphertext
(String
) -- The message to be decrypted.
def open(ciphertext) raise CryptoError, "Decryption failed. No private key." unless @private_key ct = ciphertext raise CryptoError, "Decryption failed. Ciphertext failed verification." if ct.bytesize < SEALBYTES message = Util.zeros(ct.bytesize - SEALBYTES) success = self.class.box_seal_open(message, ct, ct.bytesize, @public_key.to_s, @private_key.to_s) raise CryptoError, "Decryption failed. Ciphertext failed verification." unless success message end