Skip to content

Using PolarSSL::Cipher

Michiel Sikkes edited this page Aug 26, 2013 · 1 revision

See below this example for a list of supported ciphers:

require 'polarssl'
require 'base64'

cipher = PolarSSL::Cipher.new("AES-128-CTR")
cipher.setkey("mykey", 128, PolarSSL::Cipher::OPERATION_ENCRYPT)
cipher.update("secret stuff I want encrypted")
encrypted_data = cipher.finish()

encoded_encrypted_data = Base64.encode64(encrypted_data)
puts encoded_encrypted_data

This is a list of cipher types that you can pass into PolarSSL::Cipher.new():

CAMELLIA-128-CBC
CAMELLIA-192-CBC
CAMELLIA-256-CBC

CAMELLIA-128-CFB128
CAMELLIA-192-CFB128
CAMELLIA-256-CFB128

CAMELLIA-128-CTR
CAMELLIA-192-CTR
CAMELLIA-256-CTR

AES-128-CBC
AES-192-CBC
AES-256-CBC

AES-128-CFB128
AES-192-CFB128
AES-256-CFB128

AES-128-CTR
AES-192-CTR
AES-256-CTR

DES-CBC
DES-EDE-CBC
DES-EDE3-CBC

BLOWFISH-CBC
BLOWFISH-CFB64
BLOWFISH-CTR

NULL
Clone this wiki locally