Class: Ciphr::Functions::OpenSSL::OpenSslDigest

Inherits:
Function
  • Object
show all
Defined in:
lib/ciphr/functions/openssl.rb

Overview

TODO: fail/ignore gracefully with error/warning if openssl unavailable

Direct Known Subclasses

OpenSslHmac

Instance Attribute Summary

Attributes inherited from Function

#args, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Function

aligned, inherited, #initialize, invertable?, #prepend, #read

Constructor Details

This class inherits a constructor from Ciphr::Functions::Function

Class Method Details

.paramsObject



12
13
14
# File 'lib/ciphr/functions/openssl.rb', line 12

def self.params
  [:input]
end

.variantsObject



8
9
10
# File 'lib/ciphr/functions/openssl.rb', line 8

def self.variants
  OPENSSL_DIGESTS.map{|d| [d, {:variant => d}]}
end

Instance Method Details

#applyObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ciphr/functions/openssl.rb', line 16

def apply
  input = args[0]
  digester = OpenSSL::Digest.new(@options[:variant])
  while chunk = input.read(256)
    digester.update(chunk)
  end
  digest = digester.digest
  Proc.new do
    d = digest
    digest = nil
    d
  end
end