class method
OpenSSL::Cipher.new
(::String cipher_name) -> ::OpenSSL::Cipher
Cipher.new(string) → cipher
ext/openssl/ossl_cipher.c
View on GitHub ↗
static VALUE
ossl_cipher_initialize(VALUE self, VALUE str)
{
EVP_CIPHER_CTX *ctx;
const EVP_CIPHER *cipher;
VALUE cipher_holder;
GetCipherInit(self, ctx);
if (ctx) {
ossl_raise(rb_eRuntimeError, "Cipher already initialized!");
}
cipher = ossl_evp_cipher_fetch(str, &cipher_holder);
AllocCipher(self, ctx);
if (EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, -1) != 1)
ossl_raise(eCipherError, "EVP_CipherInit_ex");
rb_ivar_set(self, id_cipher_holder, cipher_holder);
return self;
}
The string must contain a valid cipher name like “aes-256-cbc”.
A list of cipher names is available by calling OpenSSL::Cipher.ciphers.