Class: Gitlab::InsecureKeyFingerprint
- Inherits:
-
Object
- Object
- Gitlab::InsecureKeyFingerprint
- Defined in:
- lib/gitlab/insecure_key_fingerprint.rb
Overview
Calculates the fingerprint of a given key without using openssh key validations. For this reason, only use for calculating the fingerprint to find the key with it.
DO NOT use it for checking the validity of a ssh key.
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
Instance Method Summary collapse
- #fingerprint ⇒ Object
- #fingerprint_sha256 ⇒ Object
-
#initialize(key_base64) ⇒ InsecureKeyFingerprint
constructor
Gets the base64 encoded string representing a rsa or dsa key.
Constructor Details
#initialize(key_base64) ⇒ InsecureKeyFingerprint
Gets the base64 encoded string representing a rsa or dsa key
18 19 20 |
# File 'lib/gitlab/insecure_key_fingerprint.rb', line 18 def initialize(key_base64) @key = key_base64 end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key
12 13 14 |
# File 'lib/gitlab/insecure_key_fingerprint.rb', line 12 def key @key end |
Instance Method Details
#fingerprint ⇒ Object
22 23 24 |
# File 'lib/gitlab/insecure_key_fingerprint.rb', line 22 def fingerprint OpenSSL::Digest::MD5.hexdigest(Base64.decode64(@key)).scan(/../).join(':') end |
#fingerprint_sha256 ⇒ Object
26 27 28 |
# File 'lib/gitlab/insecure_key_fingerprint.rb', line 26 def fingerprint_sha256 Digest::SHA256.base64digest(Base64.decode64(@key)).scan(/../).join('').delete("=") end |