SymmetricKey

SymmetricKey[assoc]

represents all the information needed for encryption, decryption, and other operations in a symmetric cryptographic system.

Details

  • SymmetricKey objects can be used with functions such as Encrypt and Decrypt.
  • A single SymmetricKey object can be used for both encryption and decryption.
  • In SymmetricKey[assoc], the association assoc contains the following:
  • "Cipher"cipher used
    "Key"key as a ByteArray
    "InitializationVector"initialization vector as a ByteArray or None
    "BlockMode"block chaining mode for block ciphers
  • Possible methods are as listed for GenerateSymmetricKey.
  • When used in Encrypt, the setting "InitializationVector"->None specifies that Encrypt should generate a new initialization vector whenever it is called.
  • SymmetricKey[assoc]["prop"] gives the specified element of assoc. It is equivalent to assoc["prop"].

Examples

Basic Examples  (1)

Generate a random symmetric key:

In[1]:=
Click for copyable input
Out[1]=

Use the key to encrypt:

In[2]:=
Click for copyable input
Out[2]=

Decrypt the message:

In[3]:=
Click for copyable input
Out[3]=

You can retrieve keys and values from the associations with the SymmetricKey object:

In[4]:=
Click for copyable input
Out[4]=
In[5]:=
Click for copyable input
Out[5]=
In[6]:=
Click for copyable input
Out[6]=
In[7]:=
Click for copyable input
Out[7]=

See Also

GenerateSymmetricKey  Encrypt  Decrypt  PrivateKey  PublicKey

Introduced in 2015
(10.1)