openssl: added a guide on how to en-/decrypt a file and create keys

master
TiynGER 4 years ago
parent 3bba8f5591
commit 6cec64c202

@ -0,0 +1,9 @@
# Cryptography
The practice of encryption and decryption is named cryptography.
There are various ways to permit the readability of a message.
## Linux
- [openssl](linux/openssl.md) is a big software library for secure communication
over computer networks. It can be used to encrypt and decrypt files using RSA.

@ -0,0 +1,25 @@
# OpenSSL
[OpenSSL](https://www.openssl.org) is a software library for secure
communication over computer networks.
## Creating a key pair
As described by [dreikanter](https://gist.github.com/dreikanter/c7e85598664901afae03fedff308736b)
you can create and save a pretty secure private key to `private.key` with
`openssl genrsa -aes256 -out private.key 8912`.
After that run `openssl rsa -in private.key -pubout -out public.key` to save the
according public key to `public.key`.
## Encrypting and decrypting files
[Dreikanter](https://gist.github.com/dreikanter/c7e85598664901afae03fedff308736b)
describes to encrypt larger files with symmetric encryption and encrypt the key
of that using asymmetric encryption.
If however the file is small enough to be encrypted with the public key
`public.key` directly run
`openssl rsautl -encrypt -pubin -inkey public.key -in plaintext.txt -out encrypted.txt`
where `plaintext.txt` is the message to encrypt and `encrypted.txt` is the
encrypted message.
You can decrypt the message using the private key `private.key` as follows
`openssl rsautl -decrypt -inkey private.key -in encrypted.txt -out plaintext.txt`.
Loading…
Cancel
Save