Class: FastshopCatalog::Crypto
- Inherits:
-
Object
- Object
- FastshopCatalog::Crypto
- Defined in:
- lib/fastshop_catalog/crypto.rb
Instance Method Summary collapse
- #encrypt(payload) ⇒ Object
-
#initialize(key = FastshopCatalog::Crypto.default_key, iv = FastshopCatalog::Crypto.default_iv) ⇒ Crypto
constructor
A new instance of Crypto.
Constructor Details
#initialize(key = FastshopCatalog::Crypto.default_key, iv = FastshopCatalog::Crypto.default_iv) ⇒ Crypto
Returns a new instance of Crypto.
13 14 15 16 17 18 |
# File 'lib/fastshop_catalog/crypto.rb', line 13 def initialize(key=FastshopCatalog::Crypto.default_key, iv=FastshopCatalog::Crypto.default_iv) @cypher = OpenSSL::Cipher::Cipher.new("AES-128-CBC") @cypher.encrypt @cypher.key = key @cypher.iv = iv end |
Instance Method Details
#encrypt(payload) ⇒ Object
20 21 22 23 |
# File 'lib/fastshop_catalog/crypto.rb', line 20 def encrypt(payload) encrypted = @cypher.update(payload) << @cypher.final Base64.strict_encode64(encrypted) end |