I want to randomly generate an AES 256 key. Swift provides the SecKeyGeneratePair
which is to generate an asymmetric encryption key. Is there an equivalence for generating a symmetrical encryption key?
If you are randomly generating the key, all you need to do is use a CSPRNG (cryptographically-secure psuedorandom number generator) to generate an array of 256 bits. You should use SecRandomCopyBytes
from the Randomization Services . Calling this with a count of 32 (32 bytes == 256 bits) will yield a suitable key.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.