Comment (#181)
This commit is contained in:
parent
dc91f61dba
commit
6c3748b6bf
|
@ -13,8 +13,10 @@ public struct OpenSSHKeyWriter {
|
||||||
lengthAndData(of: secret.publicKey)
|
lengthAndData(of: secret.publicKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func openSSHString<SecretType: Secret>(secret: SecretType) -> String {
|
public func openSSHString<SecretType: Secret>(secret: SecretType, comment: String? = nil) -> String {
|
||||||
"\(curveType(for: secret.algorithm, length: secret.keySize)) \(data(secret: secret).base64EncodedString())"
|
[curveType(for: secret.algorithm, length: secret.keySize), data(secret: secret).base64EncodedString(), comment]
|
||||||
|
.compactMap { $0 }
|
||||||
|
.joined(separator: " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
public func openSSHFingerprint<SecretType: Secret>(secret: SecretType) -> String {
|
public func openSSHFingerprint<SecretType: Secret>(secret: SecretType) -> String {
|
||||||
|
|
|
@ -13,7 +13,7 @@ struct SecretDetailView<SecretType: Secret>: View {
|
||||||
CopyableView(title: "Fingerprint", image: Image(systemName: "touchid"), text: keyWriter.openSSHFingerprint(secret: secret))
|
CopyableView(title: "Fingerprint", image: Image(systemName: "touchid"), text: keyWriter.openSSHFingerprint(secret: secret))
|
||||||
Spacer()
|
Spacer()
|
||||||
.frame(height: 20)
|
.frame(height: 20)
|
||||||
CopyableView(title: "Public Key", image: Image(systemName: "key"), text: keyWriter.openSSHString(secret: secret))
|
CopyableView(title: "Public Key", image: Image(systemName: "key"), text: keyString)
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,19 @@ struct SecretDetailView<SecretType: Secret>: View {
|
||||||
.frame(minHeight: 200, maxHeight: .infinity)
|
.frame(minHeight: 200, maxHeight: .infinity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var dashedKeyName: String {
|
||||||
|
secret.name.replacingOccurrences(of: " ", with: "-")
|
||||||
|
}
|
||||||
|
|
||||||
|
var dashedHostName: String {
|
||||||
|
["secretive", Host.current().localizedName, "local"]
|
||||||
|
.compactMap { $0 }
|
||||||
|
.joined(separator: ".")
|
||||||
|
.replacingOccurrences(of: " ", with: "-")
|
||||||
|
}
|
||||||
|
|
||||||
var keyString: String {
|
var keyString: String {
|
||||||
keyWriter.openSSHString(secret: secret)
|
keyWriter.openSSHString(secret: secret, comment: "\(dashedKeyName)@\(dashedHostName)")
|
||||||
}
|
}
|
||||||
|
|
||||||
func copy() {
|
func copy() {
|
||||||
|
|
Loading…
Reference in New Issue