Class: Enveloperb::Simple
- Inherits:
-
Object
- Object
- Enveloperb::Simple
- Defined in:
- lib/enveloperb/simple.rb
Overview
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
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/enveloperb/simple.rb', line 5 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
25 26 27 28 29 30 31 |
# File 'lib/enveloperb/simple.rb', line 25 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
17 18 19 20 21 22 23 |
# File 'lib/enveloperb/simple.rb', line 17 def encrypt(s) unless s.is_a?(String) raise ArgumentError, "Can only encrypt strings" end _encrypt(s) end |