Class: Enveloperb::Simple
- Inherits:
-
Object
- Object
- Enveloperb::Simple
- Defined in:
- lib/enveloperb/simple.rb
Overview
Note:
this class is not intended for general-purpose use.
An Enveloperb cryptography engine using an unprotected string as the wrapping key.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.new(k) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/enveloperb/simple.rb', line 7 def self.new(k) unless k.is_a?(String) && k.encoding == Encoding::BINARY raise ArgumentError, "Key must be a binary string" end unless k.bytesize == 16 raise ArgumentError, "Key must be 16 bytes" end _new(k) end |
Instance Method Details
#decrypt(er) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/enveloperb/simple.rb', line 27 def decrypt(er) unless er.is_a?(EncryptedRecord) raise ArgumentError, "Can only decrypt EncryptedRecord objects; you can make one from a string with EncryptedRecord.new" end _decrypt(er) end |
#encrypt(s) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/enveloperb/simple.rb', line 19 def encrypt(s) unless s.is_a?(String) raise ArgumentError, "Can only encrypt strings" end _encrypt(s) end |