Method: RbNaCl::SimpleBox#box

Defined in:
lib/rbnacl/simple_box.rb

#box(message) ⇒ String Also known as: encrypt

Encrypts the message with a random nonce

Encrypts the message with a random nonce, then returns the ciphertext with the nonce prepended. Optionally encodes the message using an encoder.

Parameters:

  • message (String)

    The message to encrypt

Returns:

  • (String)

    The enciphered message



76
77
78
79
80
# File 'lib/rbnacl/simple_box.rb', line 76

def box(message)
  nonce = generate_nonce
  cipher_text = @box.box(nonce, message)
  nonce + cipher_text
end