Cs PBL File
Cs PBL File
Cs PBL File
On
Credit card Encryption Decryption using RSA
in
Electronics & Communication Engineering
By
2014111034 Tushar Chaubey
2014111044 Sania Goyal
2014111045 Swastik Gupta
Bharati Vidyapeeth
(Deemed to be University)
College of Engineering,
Pune – 4110043
CERTIFICATE
Certified that the Project Based Learning report entitled, “Credit card Encryption Decryption
using RSA ” is work done by
in partial fulfillment of the requirements for the award of credits for Project Based Learning
(PBL) in Cyber Security of Bachelor of Technology Semester VII, in Electronics and
Communication.
Date: 25/10/2023
4 Conclusion 11
5 Project Outcome 12
6 References 13
Description of Problem Statement
RSA:
RSA involves the use of a pair of keys: a public key and a private key.
1. Public Key: This key is used for encryption and can be freely distributed. It consists of two
components: the modulus (n) and the public exponent (e). The modulus is a product of two large
prime numbers (p) and (q), and the public exponent (e) is usually a small prime number.
2. Private Key: This key is kept secret and is used for decryption. It also consists of two
components: the modulus (n) and the private exponent (d). The private exponent (d) is calculated
based on the prime factors of (n), (p), and (q), and the public exponent (e).
Encryption Process:
To encrypt a message (m) using RSA with a recipient's public key (e, n):
1. Convert the message into an integer (m) that is less than the modulus (n).
2. Compute the ciphertext (c) using the formula:
c = m^e mod n
This ciphertext (c) can be safely transmitted over insecure channels.
Decryption Process:
To decrypt the ciphertext (c) using RSA with the recipient's private key (d, n):
m = c^d mod n
Key Properties:
1. One-Way Function: RSA encryption is easy to compute, but the reverse operation (finding the
original message from the ciphertext) is considered computationally infeasible without the
private key.
2. Asymmetric: RSA uses a pair of keys: one for encryption and one for decryption. Anything
encrypted with the public key can only be decrypted with the corresponding private key and vice
versa.
3. Security: The security of RSA relies on the difficulty of factoring the product of two large
prime numbers. As long as these prime numbers remain secret and sufficiently large, RSA
encryption is secure.
RSA is widely used in various applications such as secure communication, digital signatures,
and key exchange protocols. However, due to its computational intensity for long messages, it's
often used in combination with symmetric encryption algorithms for securing data efficiently.
Credit Card Encryption using RSA:
1. Key Generation:
- Generate a pair of RSA keys: a public key and a private key.
- The public key consists of `(e, n)`, where `e` is the public exponent and `n` is the modulus.
- The private key consists of `(d, n)`, where `d` is the private exponent and `n` is the modulus.
- The security of RSA relies on the mathematical properties of large prime numbers, so ensure
you use secure methods to generate these primes.
success = key.LoadAnyFormatFile("rsaPrivateKey.key","")
if (success != True):
print(key.lastErrorText())
sys.exit()
keyXml = key.getXml()
success = rsa.ImportPublicKey(keyXml)
if (success != True):
print(rsa.lastErrorText())
sys.exit()
usePrivateKey = False
rsa.put_EncodingMode("base64")
encryptedcc = rsa.encryptStringENC(ccNumber,usePrivateKey)
print("Encrypted:")
print(encryptedcc)
encryptedCVV = rsa.encryptStringENC(CVV,usePrivateKey)
print("Encrypted:")
print(encryptedCVV)
encryptedName = rsa.encryptStringENC(Name,usePrivateKey)
print("Encrypted:")
print(encryptedName)
# Now decrypt:
rsaDecryptor = chilkat.CkRsa()
rsaDecryptor.put_EncodingMode("base64")
success = rsaDecryptor.ImportPrivateKey(keyXml)
usePrivateKey = True
decryptedcc = rsaDecryptor.decryptStringENC(encryptedcc,usePrivateKey)
decryptedCVV = rsaDecryptor.decryptStringENC(encryptedCVV,usePrivateKey)
decryptedName = rsaDecryptor.decryptStringENC(encryptedName,usePrivateKey)
print("Decrypted:")
print(decryptedcc)
print("Decrypted:")
print(decryptedCVV)
print("Decrypted:")
print(decryptedName)
Hence, in this Project-Based Learning, on the topic- ‘Credit card encryption decryption using
RSA.’ we have studied about the RSA algorithm and about credit card encryption and decryption
and performed its code in Python programming language. Overall, the understanding was
developed, and all the related concepts were understood well and performed using Python
programming language.
Project Outcome
Here, in this Project-Based Learning, under Course Outcome 4 (CO4): Analyse and evaluate the
digital payment system security and remedial measures against digital payment frauds. The
concepts were understood and performed using Python.
References
[1] What Is RSA Algorithm and How Does It Work in Cryptography?, Simplilearn, accessed
21 October 2023,< https://www.simplilearn.com/tutorials/cryptography-tutorial/rsa-algorithm>
[3] JULIA KAGAN,Updated July 27, 2023,Credit Card Authentication: What It Is and How
It Works, Investopedia, Edmonton, Canada,accessed 23 October 2023,<
https://www.investopedia.com/terms/c/credit-card-authentication.asp#:~:text=Credit%20card
%20encryption%20is%20a,information%2C%20such%20as%20account%20numbers.&text=A
%20card%20recovery%20bulletin%20is,been%20replaced%20by%20newer%20methods.>