-
-
Save seanlilmateus/0b5b702c5d0ff34302b5582a83c0104c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getPublicKey64() -> String? { | |
var error: UnsafeMutablePointer<Unmanaged<CFError>?>? | |
let publicK = SecKeyCopyExternalRepresentation(self.publicKey!, error) as Data? | |
let exportedPublicK = publicK?.base64EncodedString() | |
print("exported PublicK ",exportedPublicK!) | |
return exportedPublicK! as String | |
} | |
func getPrivateKey64() -> String? { | |
var error: UnsafeMutablePointer<Unmanaged<CFError>?>? | |
let privateK = SecKeyCopyExternalRepresentation(self.privateKey!, error) as Data? | |
let exportedPrivateK = privateK?.base64EncodedString() | |
print("exported PrivateK ",exportedPrivateK) | |
return exportedPrivateK! as String | |
} | |
func putPublicKey64(publicK:String, keySize: UInt, publicTag: String) { | |
let secKeyData : NSData = NSData(base64Encoded: publicK, options: .ignoreUnknownCharacters)! | |
putPublicKey(publicK: secKeyData as Data, keySize: keySize, publicTag: publicTag) | |
} | |
func putPrivateKey64(privateK:String, keySize: UInt, privateTag: String) { | |
let secKeyData : NSData = NSData(base64Encoded: privateK, options: .ignoreUnknownCharacters)! | |
putPrivateKey(privateK: secKeyData as Data, keySize: keySize, privateTag: privateTag) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment