Module: Encryptor

Extended by:
Encryptor
Included in:
Encryptor
Defined in:
lib/encryptor.rb,
lib/encryptor/string.rb,
lib/encryptor/version.rb

Overview

A simple wrapper for the standard OpenSSL library

Defined Under Namespace

Modules: String, Version

Instance Method Summary collapse

Instance Method Details

#decrypt(*args) ⇒ Object

Decrypts a :value with a specified :key

Optionally accepts :iv and :algorithm options

Example

decrypted_value = Encryptor.decrypt(:value => 'some encrypted string', :key => 'some secret key')
# or
decrypted_value = Encryptor.decrypt('some encrypted string', :key => 'some secret key')


43
44
45
# File 'lib/encryptor.rb', line 43

def decrypt(*args)
  crypt :decrypt, *args
end

#default_optionsObject

The default options to use when calling the encrypt and decrypt methods

Defaults to { :algorithm => ‘aes-256-cbc’ }

Run ‘openssl list-cipher-commands’ in your terminal to view a list all cipher algorithms that are supported on your platform



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

def default_options
  @default_options ||= { :algorithm => 'aes-256-cbc' }
end

#encrypt(*args) ⇒ Object

Encrypts a :value with a specified :key

Optionally accepts :iv and :algorithm options

Example

encrypted_value = Encryptor.encrypt(:value => 'some string to encrypt', :key => 'some secret key')
# or
encrypted_value = Encryptor.encrypt('some string to encrypt', :key => 'some secret key')


30
31
32
# File 'lib/encryptor.rb', line 30

def encrypt(*args)
  crypt :encrypt, *args
end