Use Symmetric Key Encryption and Decryption
Symmetric key encryption allows for ciphertext to be encrypted and decrypted with the same key.
Generate a key with the default settings.
In[1]:=
![Click for copyable input](assets.en/use-symmetric-key-encryption-and-decryption/In_25.png)
key = GenerateSymmetricKey[]
Out[1]=
![](assets.en/use-symmetric-key-encryption-and-decryption/O_20.png)
Encrypt a message using this key.
In[2]:=
![Click for copyable input](assets.en/use-symmetric-key-encryption-and-decryption/In_26.png)
encrypted =
Encrypt[key, "I hid the gold on an island in the Caribbean."]
Out[2]=
![](assets.en/use-symmetric-key-encryption-and-decryption/O_21.png)
Using the same key, decrypt the message.
In[3]:=
![Click for copyable input](assets.en/use-symmetric-key-encryption-and-decryption/In_27.png)
Decrypt[key, encrypted]
Out[3]=
![](assets.en/use-symmetric-key-encryption-and-decryption/O_22.png)