用密码对表达式进行加密保护
用简单的密码 "Shiver me timbers!" 对一条消息进行加密,因而产生一个 EncryptedObject.
In[1]:=
![Click for copyable input](assets.zh/password-protect-an-expression-with-encrypt/In_22.png)
secretMessage =
Encrypt["Shiver me timbers!", "I buried a stash of gold somewhere."]
Out[1]=
![](assets.zh/password-protect-an-expression-with-encrypt/O_17.png)
数据处于加密状态.
In[2]:=
![Click for copyable input](assets.zh/password-protect-an-expression-with-encrypt/In_23.png)
InputForm[secretMessage]
Out[2]//InputForm=
![](assets.zh/password-protect-an-expression-with-encrypt/O_18.png)
用同样的密码进行解密.
In[3]:=
![Click for copyable input](assets.zh/password-protect-an-expression-with-encrypt/In_24.png)
Decrypt["Shiver me timbers!", secretMessage]
Out[3]=
![](assets.zh/password-protect-an-expression-with-encrypt/O_19.png)