class RbNaCl::Boxes::Sealed

def box(message)

Returns:
  • (String) - The ciphertext (BINARY encoded)

Raises:
  • (RbNaCl::CryptoError) - If the encrytion fails.

Parameters:
  • message (String) -- The message to be encrypted.
def box(message)
  # No padding needed.
  msg = message # variable name to match other RbNaCl code.
  # ensure enough space in result
  ct  = Util.zeros(msg.bytesize + SEALBYTES)
  success = self.class.box_seal(ct, msg, msg.bytesize, @public_key.to_s)
  raise CryptoError, "Encryption failed" unless success
  ct
end