Module: NmDatafile::Blowfish
- Defined in:
- lib/nm_datafile/blowfish.rb
Class Method Summary collapse
Class Method Details
.cipher(mode, key, data) ⇒ Object
8 9 10 11 12 |
# File 'lib/nm_datafile/blowfish.rb', line 8 def self.cipher(mode, key, data) cipher = OpenSSL::Cipher::Cipher.new('bf-cbc').send(mode) cipher.key = Digest::SHA256.digest(key) cipher.update(data) << cipher.final end |
.decrypt(key, text) ⇒ Object
18 19 20 |
# File 'lib/nm_datafile/blowfish.rb', line 18 def self.decrypt(key, text) cipher(:decrypt, key, text) end |
.encrypt(key, data) ⇒ Object
14 15 16 |
# File 'lib/nm_datafile/blowfish.rb', line 14 def self.encrypt(key, data) cipher(:encrypt, key, data) end |