Giter Club home page Giter Club logo

encrypt-decrypt-with-openssl---rsa's Introduction

Encrypt-Decrypt-with-OpenSSL-RSA

What is OpenSSL ?

OpenSSL is opensource library that provide secure communication over networks using TLS (Transfer Secure Layer) and SSL (Secure Socket Layer). It supports many cryptographic algorithm AES, DSA, RSA, SHA1, SHA2, MD5.. More information about OpenSSL

What is RSA ?

RSA is algorithm using for encrypting and decrypting data. It is in the class of asymmetric cryptographic algorithm (public key cryptography). Asymmetric cryptographic algorithm has two different keys. They are public key and private key. Public key is given everyone. Private key is secret. Data is encrypted by public key then decrypted by private key. More information about RSA Algorithm

Steps of RSA Algorithm

1 - Define two different prime numbers. ( p and q)
2 - Calculate modulus for private key and public key. n = p * q
3 - Caluclate totient. Q(n) = (p -1) * (q -1)
4 - Define public key exponent (e). e must be in 1 < e < Q(n). e and Q(n) are relatively prime.
5 - Define private key exponent (d). It must be secret. d*e = 1 + kQ(n). d must be in 1 < d < Q(n)

Encrypt Message

c = m^e mod (n)

Decrypt Message

m = c^d mod (n)

Sample

1 - p = 3 and q = 11
2 - modulus n = 3 * 11 = 33
3 - totient Q(n) = (3 - 1) * (11 - 1) = 20
4 - 1 < e < 20 and e = 7
5 - de mod Q(n) = 1 and 7d mod 20 = 1, d = 3

Message can be 4. m = 4
Encrypt message: c = 4^7 mod (33) = 16384 mod (33) and c = 16. Encrypted message is 16
Decrypt message: m = 16^3 mod (33) = 4096 mod (33) and m = 4. Decrypted message is 4

Project Code

This project encrypts and decrypts message in a simple way. Let's examine openssl_rsa.h file.

create_RSA function creates public_key.pem and private_key.pem file. Public_key.pem file is used to encrypt message. Private_key.pem file is used to decrypt message.

public_encrypt function encrypts message using public_key.pem file

private_decrypt function decrypts encrypted message using private_key.pem

create_encrypted_file function creates encryted file as .bin file.

Compilation Process

For compile the entire project

 make

For clean the project directory

 make clean

For clean the project directory and remove generated files during execution

 make deep_clean

Docker build and run

For docker build to create an image named opensslapp

docker build --tag opensslapp .

For run image as container

docker run -i -t --rm opensslapp

encrypt-decrypt-with-openssl---rsa's People

Contributors

arghyabi avatar batuhanavlayan avatar bavlayan avatar bensuperpc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

encrypt-decrypt-with-openssl---rsa's Issues

Cann't compile this.

Cann't compile this.

g++ -m32 -O3 -o rsa_encrypt_decrypt.exe main.cpp

main.cpp:3:25: fatal error: openssl/rsa.h: No such file or directory

Do you have binaries? Can you put this in releases?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.