Created
January 16, 2021 22:03
-
-
Save ricardopsantos/92a1081e9bdd3a55639d04d533e93d33 to your computer and use it in GitHub Desktop.
Article11_G2.swif
This file contains 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
print("aliceSecret: \(aliceSecret)\n") | |
// Sender: Generating symmetric key and encrpting data USING shared symmetric key | |
let senderSymmetricKey = CryptoKit.generateSymmetricKeyBetween(AliceSender.privateKey, and: BobReceiver.publicKey, salt: salt)! | |
let encryptedData = CryptoKit.encrypt(data: aliceSecretData!, using: senderSymmetricKey)! | |
// Receiver: Generating symmetric key and decrypting data USING shared symmetric key | |
let reveiverSymmetricKey = CryptoKit.generateSymmetricKeyBetween(BobReceiver.privateKey, and: AliceSender.publicKey, salt: salt)! | |
let decryptedData = CryptoKit.decrypt(encryptedData: encryptedData, using: reveiverSymmetricKey) | |
let bobSecret = String(data: decryptedData!, encoding: .utf8)! | |
print("bobSecret: \(bobSecret)\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment