Class: Cript::Naive
Overview
Cript::Naive uses rsa keys to encrypt data. It allows you to easily encrypt and decrypt strings. Performance is poor because rsa public keys were not meant to do this.
Instance Method Summary collapse
Methods inherited from Cripter
Constructor Details
This class inherits a constructor from Cript::Cripter
Instance Method Details
#decrypt(message) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/cript/naive.rb', line 22 def decrypt() Base64::decode64(). bytes. each_slice(size / 8). map { |chunk| @private_key.private_decrypt(chunk.pack('C*')) }. join end |
#encrypt(message) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/cript/naive.rb', line 13 def encrypt() Base64::encode64( . bytes. each_slice((size / 8) - 11). map { |chunk| @public_key.public_encrypt(chunk.pack('C*')) }. join) end |