Click here to Skip to main content
15,867,308 members
Articles / Desktop Programming / MFC
Article

RSA encryption/decryption

Rate me:
Please Sign up or sign in to vote.
2.92/5 (40 votes)
5 May 20032 min read 284K   16.9K   41   29
Find a RSA implementation in VC++. Key size is 32-bit.

Introduction

Note: Please refer rsa.doc for more details on code and software. I can be contacted at bhaskar_bora@yahoo.com for further queries. Implementation includes private and public key (32-bit) generation and support of text file encryption and decryption. This document contains the algorithms and information required to design and implement RSA algorithm in VC++. This software is only for text data encryption and decryption. Document also contains the software usage guidelines and screen-shots.

Intro to RSA

RSA algorithm is mainly a public key encryption technique used widely in network communication like in Virtual Private Networks (VPNs). In public key encryption technique, a key is split into two keys and they are called as public and private keys. Public key is advertised to the world and private key is kept secret. It is not possible to generate private key using the public key. So, someone who knows the public key cannot decrypt a message after it has been encrypted using the public key.

RSA algorithm is a block cipher technique in which plain text and cipher text are integers between ‘0’ and ‘n-1’ from some ‘n’. In RSA algorithm encryption and decryption are of following form, for some plain text M and cipher text C:

C = M^e mod n

M = C^d mod n

Both sender and receiver must know the value of ‘n’. The sender knows the value of ‘e’ and only receiver knows the value of ‘d’. Thus, this is a public-key encryption algorithm with a public key of KU={e, n} and private key of KR={d, n}. For the algorithm to be satisfactory for public-key encryption, the following requirement must be met

  1. It is possible to find values of e, d, n such that M^ed = M mod n for all M<n.
  2. It is relatively easy to calculate M^e and C^d for all values of M<n.
  3. It is infeasible to determine d given e and n.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
India India
Working with EMC Corp, Bangalore (India) in distributed embedded software design. Like to read and code in storage, computer security and language design areas.

Comments and Discussions

 
Questionx, y, z are not getting encrypt/decript Pin
Member 413262526-Oct-15 16:29
Member 413262526-Oct-15 16:29 
AnswerRe: x, y, z are not getting encrypt/decript Pin
Member 112950792-Nov-15 10:37
Member 112950792-Nov-15 10:37 
QuestionUnicodes in encrypted files. Pin
NIKHIL788 Agrawal4-Dec-12 7:02
NIKHIL788 Agrawal4-Dec-12 7:02 
Questionhelp Pin
steven stevanus23-Feb-12 17:01
steven stevanus23-Feb-12 17:01 
Questionhelp Pin
steven stevanus23-Feb-12 17:00
steven stevanus23-Feb-12 17:00 
Questionis your software Encrypt/Decrypt the text by 128 bit key Pin
Raj.Amit29-Jul-10 21:51
Raj.Amit29-Jul-10 21:51 
GeneralMy vote of 1 Pin
KarstenK6-Jun-10 21:26
mveKarstenK6-Jun-10 21:26 
Questionhow to run it in VS 2008? Pin
adam syria5-Apr-10 12:53
adam syria5-Apr-10 12:53 
GeneralThanks need help Pin
tnla9-Nov-09 8:27
tnla9-Nov-09 8:27 
GeneralMy vote of 1 Pin
Walxer2-Nov-09 9:44
Walxer2-Nov-09 9:44 
Generaldecrpter for data in SHA1/RSA format.mdb file Pin
oviis_4u3-May-09 4:40
oviis_4u3-May-09 4:40 
GeneralRe: decrpter for data in SHA1/RSA format.mdb file Pin
hebbiche26-May-09 11:17
hebbiche26-May-09 11:17 
GeneralMy vote of 1 Pin
Kirk211221-Apr-09 8:54
Kirk211221-Apr-09 8:54 
GeneralNeed help ! Pin
Hackmahesh4-Apr-09 7:52
Hackmahesh4-Apr-09 7:52 
GeneralMy vote of 1 Pin
villecoder22-Dec-08 9:10
villecoder22-Dec-08 9:10 
Questionkamine kutte ye kya tha????????? Pin
anubhavkapuuri28-Nov-08 3:31
anubhavkapuuri28-Nov-08 3:31 
Generali can't run program! Pin
nguyenvanchinh1214-Nov-08 23:37
nguyenvanchinh1214-Nov-08 23:37 
QuestionHOW TO HANDEL 128 BIT KEY GENARETION Pin
tandra islam21-Apr-08 7:56
tandra islam21-Apr-08 7:56 
QuestionHow to handle 521 bit encryption/decryption Pin
Yiping Zou21-Jun-04 16:01
Yiping Zou21-Jun-04 16:01 
GeneralDoesn't work for N less than the biggest ASCII code, which is Your default Pin
Maxim Violin31-Jan-04 0:44
Maxim Violin31-Jan-04 0:44 
GeneralRe: Doesn't work for N less than the biggest ASCII code, which is Your default Pin
BhaskarBora13-Dec-04 22:53
BhaskarBora13-Dec-04 22:53 
GeneralRe: Doesn't work for N less than the biggest ASCII code, which is Your default Pin
bygreencn10-Dec-06 16:48
bygreencn10-Dec-06 16:48 
QuestionUsing linear search to check if a number is prime or not? Pin
Mustafa Demirhan6-May-03 8:39
Mustafa Demirhan6-May-03 8:39 
GeneralRe: 32 Bits!!! Pin
Niklas L6-May-03 2:14
Niklas L6-May-03 2:14 
GeneralRe: 32 Bits!!! Pin
Jörgen Sigvardsson6-May-03 6:06
Jörgen Sigvardsson6-May-03 6:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.