class Ciphr::Functions::OpenSSL::OpenSslCipher
Public Class Methods
params()
click to toggle source
# File lib/ciphr/functions/openssl.rb, line 100 def self.params [:input, :key] end
variants()
click to toggle source
# File lib/ciphr/functions/openssl.rb, line 94 def self.variants OpenSSL::Cipher.ciphers.map{|c| c.downcase}.uniq.map do |c| [[c, c.gsub(/-/, "")], {:variant => c}] end end
Public Instance Methods
apply()
click to toggle source
# File lib/ciphr/functions/openssl.rb, line 59 def apply input, key = @args cipher = OpenSSL::Cipher.new(@options[:variant]) cipher.send(invert ? :decrypt : :encrypt) cipher.key = key.read random_iv = cipher.random_iv if random_iv.size > 0 cipher.iv = invert ? input.read(random_iv.size) : random_iv end Proc.new do if ! invert && random_iv begin random_iv ensure random_iv = nil end else chunk = input.read(256) if cipher if chunk cipher.update(chunk) else begin cipher.final ensure cipher = nil end end else nil end end end end