Encryptで式にパスワードを設定してプロテクトをかける
簡単なパスワード「Shiver me timbers!」を使ってメッセージを暗号化し,EncryptedObjectを得る.
In[1]:=
![Click for copyable input](assets.ja/password-protect-an-expression-with-encrypt/In_23.png)
secretMessage =
Encrypt["Shiver me timbers!", "I buried a stash of gold somewhere."]
Out[1]=
![](assets.ja/password-protect-an-expression-with-encrypt/O_18.png)
データは暗号化された.
In[2]:=
![Click for copyable input](assets.ja/password-protect-an-expression-with-encrypt/In_24.png)
InputForm[secretMessage]
Out[2]//InputForm=
![](assets.ja/password-protect-an-expression-with-encrypt/O_19.png)
同じパスワードを使ってデータの暗号解読を行う.
In[3]:=
![Click for copyable input](assets.ja/password-protect-an-expression-with-encrypt/In_25.png)
Decrypt["Shiver me timbers!", secretMessage]
Out[3]=
![](assets.ja/password-protect-an-expression-with-encrypt/O_20.png)