This blog I show my way of how to Advanced Encryption Standard with Swift Language.
I will use framework CryptoKit and your resource AES.
To perform the cryptography is necessary a key and message.
I use message "AES Cryptography" and aleatory key that received by SymmetricKey of bits 256.
So, whats happening in this code?
Firstly, created a aleatory key using SymmetricKey and defines the message data that we want encrypt.
And next, use AES.GCM to storaged in SealedBox.
Right, your message has encrypt!
To decrypt this message, use AES.GCM.open passing your sealedBox and key.
Case need encrypt message with definitive key, change .init of SymmetricKey for this:
let key = SymmetricKey(data: "{YOUR_KEY}".data(using: .utf8)!)
Top comments (0)