Add SHA256

This commit is contained in:
Max Goedjen
2021-01-17 14:03:09 -08:00
parent 6c3748b6bf
commit 7d818593a6
2 changed files with 9 additions and 2 deletions

View File

@@ -19,7 +19,11 @@ public struct OpenSSHKeyWriter {
.joined(separator: " ")
}
public func openSSHFingerprint<SecretType: Secret>(secret: SecretType) -> String {
public func openSSHSHA256Fingerprint<SecretType: Secret>(secret: SecretType) -> String {
Data(SHA256.hash(data: data(secret: secret))).base64EncodedString()
}
public func openSSHMD5Fingerprint<SecretType: Secret>(secret: SecretType) -> String {
Insecure.MD5.hash(data: data(secret: secret))
.compactMap { ("0" + String($0, radix: 16, uppercase: false)).suffix(2) }
.joined(separator: ":")