Module: Cipher64

Defined in:
lib/cipher64.rb,
lib/cipher64/version.rb

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.decrypt(key, text) ⇒ Object



11
12
13
14
# File 'lib/cipher64.rb', line 11

def self.decrypt(key, text)
  data = cipher(:decrypt, key, text)
  data[0...-1] # Remove the 'A' suffix
end

.decrypt_base64(key, base64_string) ⇒ Object



21
22
23
24
# File 'lib/cipher64.rb', line 21

def self.decrypt_base64(key, base64_string)
  blowfish_string = Base64.decode64(base64_string)
  self.decrypt(key, blowfish_string)
end

.encrypt(key, data) ⇒ Object



6
7
8
9
# File 'lib/cipher64.rb', line 6

def self.encrypt(key, data)
  data += 'A' # Add 'A' suffix to support empty data
  cipher(:encrypt, key, data)
end

.encrypt_base64(key, data) ⇒ Object



16
17
18
19
# File 'lib/cipher64.rb', line 16

def self.encrypt_base64(key, data)
  blowfish_string = self.encrypt(key, data)
  Base64.encode64(blowfish_string)
end