用非对称密钥加密
非对称密钥加密要求生成公钥和私钥,用“公”钥对消息加密,但是用“私”钥解密.
生成非对称密钥对.
In[1]:=
keys = GenerateAsymmetricKeyPair[]
Out[1]=
用公钥对消息加密.
In[2]:=
encrypted =
Encrypt[keys["PublicKey"],
"The gold is located off the coast of Honduras."]
Out[2]=
不能用为之加密的公钥来对消息解密. 必须使用私钥.
In[3]:=
Decrypt[keys["PublicKey"], encrypted]
Out[3]=
In[4]:=
Decrypt[keys["PrivateKey"], encrypted]
Out[4]=