Advanced Blockchain Development
上QQ阅读APP看书,第一时间看更新

Encryption

Taking the private key generated in the previous example, the command to encrypt a text file message.txt can be constructed as shown here:

$ echo datatoencrypt > message.txt
   
$ openssl rsautl -encrypt -inkey publickey.pem -pubin -in message.txt \
-out message.rsa

This will produce a file named message.rsa, which is in a binary format. If you open message.rsa in the nano editor or any other text editor of your choice, it will show some garbage as shown in the following screenshot:

message.rsa showing garbage (encrypted) data