Class: CryptBufferInputConverter
- Inherits:
-
Object
- Object
- CryptBufferInputConverter
- Defined in:
- lib/crypto-toolbox/crypt_buffer_input_converter.rb
Instance Method Summary collapse
- #convert(input) ⇒ Object
- #from_base64(input) ⇒ Object
-
#from_hex(input) ⇒ Object
Make sure input strings are always interpreted as hex strings This is especially useful for unknown or uncertain inputs like strings with or without leading 0x.
Instance Method Details
#convert(input) ⇒ Object
4 5 6 |
# File 'lib/crypto-toolbox/crypt_buffer_input_converter.rb', line 4 def convert(input) bytes_from_any(input) end |
#from_base64(input) ⇒ Object
19 20 21 22 |
# File 'lib/crypto-toolbox/crypt_buffer_input_converter.rb', line 19 def from_base64(input) string = Base64.decode64(input) CryptBuffer.new(str2bytes(string)) end |
#from_hex(input) ⇒ Object
Make sure input strings are always interpreted as hex strings This is especially useful for unknown or uncertain inputs like strings with or without leading 0x
11 12 13 14 15 16 17 |
# File 'lib/crypto-toolbox/crypt_buffer_input_converter.rb', line 11 def from_hex(input) hexstr ="" unless input.nil? hexstr = normalize_hex(input) end CryptBuffer.new(hex2bytes(hexstr)) end |