Cheat Sheet
Create private key RSA 2048
command
openssl genrsa -aes256 -out priv.key 2048
cat priv.key
output
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,0430E8D474E0D274BEC12DAF838E9312
km0RZDmx8pUI+BxwS2uuvGWdFIurnpya7rY9yrR2PUbmIQWN9YvlB5qNZ11ZfUaP
IAcXtZ29vPJ3KSIUfZCy/dA7amC0adPA0btR3gzE4+mCO/a/cOzJ9zS5JYGJK+EK
D+qWEjuqACINz43ZGzlfhY6WdQGL19xQmwy0rYMOGtsvi0Do9MiczSSj0QVyx1Vb
TszJx5BzyDIorXaiOMTnbAhjgjPyx/BmSd92q3GfHXUHsuG1tmqlS9U0cpNEtEEO
EPoyTzFebeqhLx6Z1gsFcD/oxMmZHiSxQnW+bl26KruGcd5yFG48/mq7JQ0usuC9
RxGFT/JoRHfEUP9/6BqwqIowQoWRxu/IlCXuWtPGXREypK+yyla+76IU33rzX6VV
XgZfZyWjTCpdjyU9AlDkUeaYX/PYRdChl02iWLIsZjub28TwtIheY4qSDDn8uw61
+FI9XkZKlkJDBviTuqqcVrUffhpQdxEnj/UAbyKRvzrbdyTGjVc9Jy+XnLBMI6AZ
dfs1bYa2axs7xt8bI1S707GkoRcx7DeLRjZXRgvShZ+Fuu0Qb4eHZHP6DKRe6Inh
uCA4XJZYPtKq5FY7jTxibgGnihnCufcarvapUgYEznieRxGJCsJOCBtB7bsWZfIy
0eSYD7lIV/hVzBV9AzTksp/uVcspmTiiQgmDWqbTIquA3R4bQb+/bPzYpYsJjP8y
/8sGxPuTcOmeJJdRPnG31R39HTqMrNPIlU+seUXJY2WQTWEEMIAaxrNFSWN9LunO
3JcoizTQaRazzJ2M7IgIhV7VWtwyH2Kw0r6k+2pM3VWa9W9Py4r774x9rhfJHmy8
o3ugV1hnf61MFCOGVR/IjpFGiC7IEDDfnm6gTxwu6BBOExkO++2emdajV2hU5R+t
hQ3/7lyw344v7H0rcWCr/d5g4rGqwDe9MpmFV7B9xRKP8JdWcyvX26e9Nme6igF5
bPkbXEKLqprxWlAZkZOdREOFPCU8e6lQP3/u2wb9ANAe9oharEd1SFFQSDNG55H5
jgK9RnQusOL0P6VQ1O8kbgMaNsYzoP3zifJJKtFyD4y0/zdrLzy7x+xYSWQwZ9vC
8gQP2HonL2L/7BA9cSbtFY9TrtdgEw1giaFXMFrb7/TWBiwTQmW1xYFTcucfsD32
hjJmk9p+5Kon6dAw6G5hSQIpr6kxmfzanYXrx6Xhvvi1D1Fc4Z8BgaQbecmzvpz3
Op6kdS5MlOqxpRUqaiyx4gVwHmxVh/EX5AbbIPBXU84i3HcD5L3h1AbSHQItf/oT
XWGr9uPCSYPqFJLFWuStCoDBH9REJ1MkiA1pCBaJ4FFy/R2fCWdCam04/f2ifBNJ
SBRuDKt7MjGGJMRWNR/OX0asaGZcw1CgnBRQ/eC7+ygnzkOZxq39xYEDgeZ01R//
sa7LLtLM0dXUA4mXqpBLhk+TybHXM3e7ZAFXN6VNr2OU0PeMNfjqCBZTapftSoWb
hAoDRIUTBpRSZFhZzGI+DIqd4eClM+dV9IuvgyiQRDdf6FWZEuNQWE56LuqQ01T9
Bb5RXNViRuk4bXhZ8c5wmCEvV7uvLeIOzYegyKVEoSd24iHKpCJ7IV91xxyAhAiy
-----END RSA PRIVATE KEY-----
Extract public key from private key
command
openssl rsa -in priv.key -pubout > pub.key
cat pub.key
output
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA59XMC4kvnHTRuV4P0sZh
o/fLGNaukP7v3ZwnxVzY5VoXXHyaevh6XzseKd8NQbL5k07AKNou0UHXoEON0685
8RuEmMlFwokOpi5elht1+jFIWlxMQ2l6/jHsTk6F/CpiC9ErakLgt5p6nK5B2e9z
LjWUT3G3yAbb5XQQtDfwuqnf4GDTBS5/VOZRx6FLOo5lA6CK9QYGVh0WoBHPsU+n
yzwf/kSP0/+YcBxqfhMIBGnaXTYk22CI3k9DKawwBW/za7a3JdswBFlxqLbMazil
YWPSqj7qVrFbsI1oaYBn1KkbJUWbt1HiUIb9dGNYubvGteWbrj7SyhOAfjL0GF0N
jQIDAQAB
-----END PUBLIC KEY-----
File encrypt with public key
command
openssl rsautl -encrypt -pubin -inkey pub.key -in plain.txt -out enc.txt
Decrypt file with a private key
openssl rsautl -decrypt -inkey priv.key -in enc.txt -out plain.txt
Top comments (0)