Hello everyone, this is IRISnoir from Hackingarise.

And I’m bringing to you another tutorial. This time, it’s about performing asymmetric encryption.

Asymmetric Encryption

First, have this installed:
openssl-tool because it’s the command line interface for encrypting files.

Now, let me explain what all of this mean:

Encryption is the act of concealing data using a special cipher.9

Ciphers (Cyphers) are the algorithms for encrypting data. The numbers of algorithms are vast but the best ones are the AES algorithm. These are the ones I will be using.

Asymmetric encryption, it means encrypting data with a ‘public key’ and decrypting with ‘private key’ (Don’t worry, we’ll get to those soon enough). This is the opposite of symmetric encryption.

Symmetric encryption, however, works the same BUT there is a disadvantage. There are no appearant keys, the only thing you have is the ‘secret key’ (I will get to that too). That means that the decryptor can have access to the data withOUT needing a key.

Now, onto the key types.

Private key: This is the type of key used in asymmetric encryption. It is for decrypting encyphered data. It appears as a PEM (Privacy Enhanced Mail) file.

Public key: This is used in asymmetric encryption just like private keys. But this type is for encrypting data. It also appears as a PEM file.

Secret key: This is for symmetric encryption. This is technically a key but it doesn’t take any “physical” appearance like a file. Instead, it’s the cipher type that gives it all away. If the decryptor knows what cypher you use, they can be able to decrypt it with ease. This is the downside I was mentioning about.

Now, we’re done with the terminology. Let’s get to the fun part of this whole thing, shall we.

Now, to encrypt and decrypt data asymmetrically, you will need a public key (to encrypt) and a private key (to decrypt). And to generate those, all you need to do is use these commands simutaneously:

Activate the command line interface with:

Step 1: A private key must be generated with:
OpenSSL> genrsa -out pri.pem -aes-256-cbc 2048

Step 2: Generate the public key based on the private key:
rsa -in pri.pem -out pub.pem -outform PEM -pubout -aes-256-cbc

Step 3: Use your keys.

To encrypt:
OpenSSL> rsautl -encrypt -inkey pub.pem -pubin -ssl -oaep -in file.txt -out file_encrypted.txt

To decrypt:
openssl rsautl -decrypt -inkey pri.pem -ssl -oaep -in file_encrypted.txt -out file.txt

Note: The private key is for solving the encrypted file. Do NOT get it LEAKED.

That’s about it for this. I hope that you enjoy. If so, please share it with your friends and remember, stay safe, stay ethical as we are never responsible for your acts or any tlrouble you get yourself into.
Also, check this out: OpenSSL instruction: How to encypher and decypher files

Leave a Reply