Module: Blowfish
- Defined in:
- lib/blowfish.rb,
lib/blowfish/block.rb,
lib/blowfish/padding.rb,
lib/blowfish/version.rb,
lib/blowfish/keys/init.rb,
lib/blowfish/keys/generate.rb
Overview
This is an implementation of Blowfish – symmetric block cipher designed in 1993 by Bruce Schneier.
Defined Under Namespace
Modules: Block, Key, Padding Classes: Error, InvalidDataSizeError, UnknownPaddingModeError
Constant Summary collapse
- VERSION =
'1.0.1'
Class Method Summary collapse
-
.decrypt(data, key, options = {}) ⇒ Object
Decrypt string of data.
-
.encrypt(data, key, options = {}) ⇒ Object
Encrypt string of data.
Class Method Details
.decrypt(data, key, options = {}) ⇒ Object
Decrypt string of data.
39 40 41 42 43 44 45 |
# File 'lib/blowfish.rb', line 39 def self.decrypt(data, key, = {}) res = '' 0.step(data.size - 8, 8) do |i| res += Block.decrypt(data.byteslice(i..(i + 7)), key) end Padding.unpad(res, [:padding]) end |
.encrypt(data, key, options = {}) ⇒ Object
Encrypt string of data.
26 27 28 29 30 31 32 33 |
# File 'lib/blowfish.rb', line 26 def self.encrypt(data, key, = {}) data = Padding.pad(data, [:padding]) res = '' 0.step(data.size - 8, 8) do |i| res += Block.encrypt(data.byteslice(i..(i + 7)), key) end res end |