Module: JWA::Cipher

Defined in:
lib/jwa/cipher.rb

Overview

Helper to get OpenSSL cipher instance from a string.

Class Method Summary collapse

Class Method Details

.for(cipher_name) ⇒ Object

Ruby raises RuntimeError jRuby raises OpenSSL::Cipher::CipherError Also jRuby is sligthly more relaxed on cipher names, returning something even for aes-999-cbc, I don’t know what it is and how it works.



10
11
12
13
14
# File 'lib/jwa/cipher.rb', line 10

def for(cipher_name)
  OpenSSL::Cipher.new(cipher_name)
rescue RuntimeError, OpenSSL::Cipher::CipherError
  raise NotImplementedError, "The OpenSSL library provided by this Ruby version does not support #{cipher_name}."
end