randomly generates a SymmetricKey object suitable for use with cryptographic functions.
GenerateSymmetricKey["password"]
derives a SymmetricKey object from the password string given.
GenerateSymmetricKey[bytes]
generates a SymmetricKey object using the byte array or list of bytes directly as the key.
GenerateSymmetricKey[DerivedKey[…]]
generates a symmetric key object with a key given by the DerivedKey object.
GenerateSymmetricKey[opts]
randomly generates a symmetric key using the specified options.
GenerateSymmetricKey
randomly generates a SymmetricKey object suitable for use with cryptographic functions.
GenerateSymmetricKey["password"]
derives a SymmetricKey object from the password string given.
GenerateSymmetricKey[bytes]
generates a SymmetricKey object using the byte array or list of bytes directly as the key.
GenerateSymmetricKey[DerivedKey[…]]
generates a symmetric key object with a key given by the DerivedKey object.
GenerateSymmetricKey[opts]
randomly generates a symmetric key using the specified options.
Details and Options
- GenerateSymmetricKey[] uses a system-specific, high-entropy randomness source.
- GenerateSymmetricKey has a Method option that specifies the cryptography method to use.
- With Method->"cipher", default settings for the specified cipher are used.
- If Method option is not provided, the default cipher is used. The current default cipher is "AES256".
- Particular settings can be specified using Method->assoc, where the entries in the association assoc are:
-
"Cipher" "AES256" cipher to use "KeySize" Automatic size of key in bits - Supported ciphers, together with the default key size, include:
-
"Blowfish" 256 bits "CAST5" 256 bits "DES" 64 bits "RC4" 256 bits "IDEA" 128 bits "AES128" 128 bits "AES192" 192 bits "AES256" 256 bits - The following ciphers can use any key size that is a multiple of 8:
-
"RC4" "Blowfish" "CAST5" - GenerateSymmetricKey["password"] effectively uses GenerateDerivedKey to generate a key.
- In GenerateSymmetricKey[bytes], bytes can be a ByteArray object or a list of integers between 0 and 255. The length of bytes must match the key size of the cipher used.
Examples
open all close allBasic Examples (1)
Scope (3)
Derive a symmetric key from a password:
GenerateSymmetricKey["my password"]SameQ[GenerateSymmetricKey["foo"], GenerateSymmetricKey["foo"]]SameQ[GenerateSymmetricKey["foo"], GenerateSymmetricKey["bar"]]Methods (2)
Generate a symmetric key appropriate for encryption using Blowfish:
GenerateSymmetricKey[Method -> <|"Cipher" -> "Blowfish"|>]GenerateSymmetricKey[Method -> "Blowfish"]Generate a symmetric key with a key size of 512 bits:
GenerateSymmetricKey[Method -> <|"Cipher" -> "Blowfish", "KeySize" -> 512|>]Possible Issues (1)
Related Guides
Text
Wolfram Research (2015), GenerateSymmetricKey, Wolfram Language function, https://reference.wolfram.com/language/ref/GenerateSymmetricKey.html (updated 2019).
CMS
Wolfram Language. 2015. "GenerateSymmetricKey." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2019. https://reference.wolfram.com/language/ref/GenerateSymmetricKey.html.
APA
Wolfram Language. (2015). GenerateSymmetricKey. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GenerateSymmetricKey.html
BibTeX
@misc{reference.wolfram_2026_generatesymmetrickey, author="Wolfram Research", title="{GenerateSymmetricKey}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/GenerateSymmetricKey.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_generatesymmetrickey, organization={Wolfram Research}, title={GenerateSymmetricKey}, year={2019}, url={https://reference.wolfram.com/language/ref/GenerateSymmetricKey.html}, note=[Accessed: 12-June-2026]}