Method: Net::SSH::Authentication::PubKeyFingerprint.fingerprint
- Defined in:
- lib/net/ssh/authentication/pub_key_fingerprint.rb
.fingerprint(blob, algorithm = 'MD5') ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/net/ssh/authentication/pub_key_fingerprint.rb', line 31 def self.fingerprint(blob, algorithm='MD5') case algorithm.to_s.upcase when 'MD5' OpenSSL::Digest.hexdigest(algorithm, blob).scan(/../).join(":") when 'SHA256' "SHA256:#{Base64.encode64(OpenSSL::Digest.digest(algorithm, blob)).chomp.gsub(/=+\z/, '')}" else raise OpenSSL::Digest::DigestError, "unsupported ssh key digest #{algorithm}" end end |