Class: TweetNaCl::CryptoBox
- Inherits:
-
Object
- Object
- TweetNaCl::CryptoBox
- Defined in:
- lib/tweetnacl/crypto_box.rb
Instance Attribute Summary collapse
-
#cipher ⇒ Object
readonly
Returns the value of attribute cipher.
-
#keypair ⇒ Object
readonly
Returns the value of attribute keypair.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
- #close(message, nonce) ⇒ Object
-
#initialize(keypair = KeyPair.new) ⇒ CryptoBox
constructor
A new instance of CryptoBox.
- #open(box, nonce) ⇒ Object
Constructor Details
#initialize(keypair = KeyPair.new) ⇒ CryptoBox
Returns a new instance of CryptoBox.
5 6 7 |
# File 'lib/tweetnacl/crypto_box.rb', line 5 def initialize(keypair = KeyPair.new) @keypair = keypair end |
Instance Attribute Details
#cipher ⇒ Object (readonly)
Returns the value of attribute cipher.
3 4 5 |
# File 'lib/tweetnacl/crypto_box.rb', line 3 def cipher @cipher end |
#keypair ⇒ Object (readonly)
Returns the value of attribute keypair.
3 4 5 |
# File 'lib/tweetnacl/crypto_box.rb', line 3 def keypair @keypair end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'lib/tweetnacl/crypto_box.rb', line 3 def end |
Instance Method Details
#close(message, nonce) ⇒ Object
9 10 11 |
# File 'lib/tweetnacl/crypto_box.rb', line 9 def close(, nonce) @cipher = TweetNaCl.crypto_box(, nonce, @keypair.public_key, @keypair.secret_key) end |
#open(box, nonce) ⇒ Object
13 14 15 |
# File 'lib/tweetnacl/crypto_box.rb', line 13 def open(box, nonce) = TweetNaCl.crypto_box_open(box.cipher, nonce, @keypair.public_key, @keypair.secret_key) end |