class OpenPGP::Digest
OpenPGP
message digest algorithm.
Constants
- DEFAULT
Public Class Methods
algorithm()
click to toggle source
@return [Symbol]
# File lib/openpgp/digest.rb, line 46 def self.algorithm name.split('::').last.to_sym unless self == Digest end
digest(data)
click to toggle source
@param [String] data @return [String]
# File lib/openpgp/digest.rb, line 74 def self.digest(data) require 'digest' unless defined?(::Digest) ::Digest.const_get(algorithm).digest(data) end
for(identifier)
click to toggle source
@param [Symbol, String, Integer] identifier @return [Class]
# File lib/openpgp/digest.rb, line 20 def self.for(identifier) case identifier when Symbol then const_get(identifier.to_s.upcase) when String then const_get(identifier.upcase.to_sym) when 1 then const_get(:MD5) when 2 then const_get(:SHA1) when 3 then const_get(:RIPEMD160) when 8 then const_get(:SHA256) when 9 then const_get(:SHA384) when 10 then const_get(:SHA512) when 11 then const_get(:SHA224) end end
hexdigest(data)
click to toggle source
@param [String] data @return [String]
# File lib/openpgp/digest.rb, line 66 def self.hexdigest(data) require 'digest' unless defined?(::Digest) ::Digest.const_get(algorithm).hexdigest(data).upcase end
hexsize()
click to toggle source
@return [Integer]
# File lib/openpgp/digest.rb, line 52 def self.hexsize size * 2 end
identifier()
click to toggle source
@return [Integer]
# File lib/openpgp/digest.rb, line 40 def self.identifier const_get(:IDENTIFIER) end
size()
click to toggle source
@return [Integer]
# File lib/openpgp/digest.rb, line 58 def self.size require 'digest' unless defined?(::Digest) ::Digest.const_get(algorithm).new.digest_length end
to_i()
click to toggle source
@return [Integer]
# File lib/openpgp/digest.rb, line 36 def self.to_i() identifier end