Rsa Algorithm: Saad Bin Naeem BCS01113074 Muhammad Bilal Aslam BCS01113028 Usman Basharat BCS01113045
This document describes the RSA encryption algorithm and provides code samples for implementing it in C#. It includes sections for key generation, encryption/decryption functions, and variables/function implementation. The key generation section shows how to generate the public and private keys by selecting two prime numbers p and q, and then computing the modulus n and encryption/decryption exponents. The encryption/decryption functions use the .NET RSACryptoServiceProvider to encrypt and decrypt byte arrays. The code sample encrypts and decrypts plaintext and displays the results.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
24 views
Rsa Algorithm: Saad Bin Naeem BCS01113074 Muhammad Bilal Aslam BCS01113028 Usman Basharat BCS01113045
This document describes the RSA encryption algorithm and provides code samples for implementing it in C#. It includes sections for key generation, encryption/decryption functions, and variables/function implementation. The key generation section shows how to generate the public and private keys by selecting two prime numbers p and q, and then computing the modulus n and encryption/decryption exponents. The encryption/decryption functions use the .NET RSACryptoServiceProvider to encrypt and decrypt byte arrays. The code sample encrypts and decrypts plaintext and displays the results.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9
RSA ALGORITHM
Saad Bin Naeem BCS01113074
Muhammad Bilal Aslam BCS01113028 Usman Basharat BCS01113045
MAY 28, 2014 SUBMITTED TO: SIR WASEEM
CODE: Key generator: namespace cryptographer { public partial class Form1 : Form { int n = 0; int s = 0, d = 0; public Form1() { InitializeComponent();
}
public void btnprime_Click(object sender, EventArgs e) { int p=0, q = 0,z=0;
p = int.Parse(ptext.Text); ptext.Text = ptext.Text; q = int.Parse(qtext.Text); if ((p != 0) && (q != 0) && (p != 1) && (q != 1)) { for (int i = 2; i <= p/2; i++) { if (p % i == 0) { MessageBox.Show("enter prime number correctly"); break; } } for (int i = 2; i <= q/2; i++) { if (p % i == 0) { MessageBox.Show("enter prime number correctly"); break; } } n = p * q; z = (p - 1) * (q - 1); ntext.Text=n.ToString();
} else { MessageBox.Show("Enter prime numbers correctly");
} }
public void genratebtn_Click(object sender, EventArgs e) {
s = int.Parse(etext.Text); d = int.Parse(dtext.Text); if (n % s == 0) { MessageBox.Show("enter any other value for e which is co prime with n");
if ((d * s) % n != 1) { MessageBox.Show("Enter any other value for d"); }
} Encryption/Decryption: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Security.Cryptography;
namespace RSAEncryption { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) {