module NmDatafile::Blowfish
Public Class Methods
cipher(mode, key, data)
click to toggle source
# 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)
click to toggle source
# File lib/nm_datafile/blowfish.rb, line 18 def self.decrypt(key, text) cipher(:decrypt, key, text) end
encrypt(key, data)
click to toggle source
# File lib/nm_datafile/blowfish.rb, line 14 def self.encrypt(key, data) cipher(:encrypt, key, data) end