OPENSSL基础使用

 实验目的:掌握常见的密码学算法应用,包含des aes md5 rsa

实验环境:一台 Centos 7.2 已经安装 openssl 组件

实验原理:openssl是Linux内置的一款开源工具,实现了常见的密码算法与应用。通过openssl操作,完成各种密码算法的应用。

实验步骤:

创建一个文件,用于被加密,文件内容为12345,文件名为test.txt

 对称加密

使用 rc4 加解密

加密
openssl enc -e -rc4 -in test.txt -out test_rc4.enc

输入加密的密码

解密
openssl enc -d -rc4 -in test_rc4.enc -out test_rc4.dm

输入解密密码

 

使用 AES 加解密

openssl enc -e -aes-128-cbc -a -salt -in test.txt -out test_aes128.enc

 解密

openssl enc -d -aes-128-cbc -a -salt -in test_aes128.enc -out test_aes128.d

 使用 3DES 加解密

加密

openssl enc -e -des3 -a -salt -in test.txt -out test_des3.enc

解密
openssl enc -d -des3 -a -salt -in test_des3.enc -out test_des3.d

 

非对称加密

RSA加解密码

生成RSA密钥对

openssl genrsa -out rsa.key 1024

导出公钥

openssl rsa -in rsa.key -pubout -out rsa_pub.key

使用公钥加密文件

openssl rsautl -encrypt -in test.txt -inkey rsa_pub.key -pubin -out test_rsa.enc

使用私解解密文件

openssl rsautl -decrypt -in test_rsa.enc -inkey rsa.key -out test_rsa.c

使用公钥解密报错

openssl rsautl -decrypt -in test_rsa.enc -inkey rsa_pub.key -out test_rsa.c

通过实验的openssl 实现对称加解密与非对称加解密两种基线的加解密功能。
思考对称与非对称加解密码的流程上有何不同?为什么?

对称加密两端都是一个密码 安全性不高

非对称加密产生两个不同的密钥 加解密都需要不同的密钥安全性更高

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
分享
二维码
< <上一篇

)">
下一篇>>