Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
16 views
RSA Algorithm
Rsa algorithm
Uploaded by
poojablpoojalgowda
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save RSA Algorithm For Later
Download
Save
Save RSA Algorithm For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
16 views
RSA Algorithm
Rsa algorithm
Uploaded by
poojablpoojalgowda
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save RSA Algorithm For Later
Carousel Previous
Carousel Next
Save
Save RSA Algorithm For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 2
Search
Fullscreen
oon =) 1] limport java.math.BigInteger; ents rads priya ree je led Folder Space k m 3 impo 4 publ 5 Bigl 6 int 1p = 13.N = 7 Random r; 8 public RSA() { 96 = new Random(); 10 // returns a prime number BigInteger. probableprii 12q = BigInteger. 14.// In c equival 15 phi = ‘\Aee = Biginte. 26 DataInputstream .|27 Strin rt java.io.*; ic class RSA { nteger p, q, bitlength = 100; P.multiply(q); ent — ph = p.subtract(Bigint Tsa = new RSA(); in=new 0. 9 teststring ; ProbablePrime(bit 2 import java.util.Random; N, phi, e, d; with in the specified bit length me(bitlength, r); length, r); t= (p-1)*(q-1) eger.ONE) jnultiply(q.subtract(Biginteger.oNE)); ger -probablePrime(bitlength/2, ); W// In Clequivatent - while ( phi.gcd(e)\> 1/2 e < phi ) 18 while (pht..gcd(e) .compareto(Biginteger ONE) > 0 && e.compareto(phi) < 0 ) ¢ 19 e-add(Biginteger. one); // In © equivalent. e+1 20} 21d = e.modinverse(phi); 22} 23 7// RSA Main 24 public static void main( 25 RSA Srtngl] args) throws toexceptiony ‘atainputstream(system.in); 38 Systen. out. printin('enter the plain PeRERM) 29 teststring-in. readi ine(); 30 System. out.printin( Encryptilig String: teststring); 31, Systen.out.printin( tring + bytesTostring(teststring. getaytes())); 32/7 encrypt 33 byte[] encrypted = reprencryet(teststring getaytes()); 34 Ty Rens Out PrtnelnCahcryp ual Strtng \ta\aytes: ey bytesTostring(encrypted)); lecrypt { SAVERS 36 byteL] decrypted + fe2-decryptCencrypted); SS n¢ RAE HYRRRA SE tag ty Bub es sO bytesTostring(decrypted)) a ACIDG SH VAtRMStctngs (en SORA SEER CSS a ng HANA dae cy cee et RN NS19 e.add(BigInteger ONE) }!'//' 26 aed = e.modInverse( phi); 22} 23 // RSA Main 24 public static void main(String[ ]) args) throws ToExceptton{ JAGAN \ 25 RSA rsa = new RSA(); 26 DataInputstream in=new DataInputstream(systen. 3 i Pash 27 String teststring ; \ avy 28 Systen.out.println("Enter the plain text:!)3))!)\ : t 29 teststring=in.readLine(); i | Prada 30 System.out.println("Encrypting String: " + teststring);, | | iste 31 System.out.println("String in Bytes: " + bytesTostring(teststring. getBytes())); i 32 // encrypt 33 byte[] encrypted = rsa. encrypt(teststring. getBytes()); 34 System. out.println("Encrypted String tn Bytes: " + bytestostring(encrypted)); } 35 // decrypt | iit 36 byte[] decrypted = rsa-decrypt(encrypted); TN EAA 37 System.out.printtn("Decrypted String in Bytes; |'\ + bytesToString(decrypted)); 38 System.out.printLn("Decrypted string: ")3) AR 39 System. out. printLn(new String(decrypted)); { 40} ! { \ nail 41 private static String bytestostring(byteL] encrypted) WANA 42 String test = \ i 43 for (byte b : encrypted) { 44 test += Byte. toString(b); 45} i 46 return test; Hilt 47} 48 // Encrypt message 49 public byte[] encrypt(byte[] message) { 50 return (new BigInteger(message)),modPow(e, N). toByteArray(.); 51} \ 52 // Decrypt message UT eee 53 public byte[] decrypt(byte[] ada { \ | 54 return (new Btornteget (es sauH) modPow(d,| N). toby tearray();\ \ ut SS ity | i , 56 }| ! \ i Hit
You might also like
Cover Matakuliah
PDF
No ratings yet
Cover Matakuliah
6 pages
Ics Assignment 1 Rsa (1) (1) .Odt
PDF
No ratings yet
Ics Assignment 1 Rsa (1) (1) .Odt
6 pages
RSA Code in Java
PDF
No ratings yet
RSA Code in Java
3 pages
Java RSA
PDF
No ratings yet
Java RSA
2 pages
Java 4
PDF
No ratings yet
Java 4
6 pages
Lab Programs For Information Security Lab
PDF
100% (1)
Lab Programs For Information Security Lab
19 pages
Java Source Code
PDF
No ratings yet
Java Source Code
6 pages
All Cns Code
PDF
No ratings yet
All Cns Code
9 pages
import java
PDF
No ratings yet
import java
3 pages
CNStasks
PDF
No ratings yet
CNStasks
4 pages
Refer Manual Refer Manual: Computer Networks Lab (CBCS 2018 Aug-Dec)
PDF
No ratings yet
Refer Manual Refer Manual: Computer Networks Lab (CBCS 2018 Aug-Dec)
4 pages
Lab P9
PDF
No ratings yet
Lab P9
2 pages
C Code To Implement RSA Algorithm
PDF
No ratings yet
C Code To Implement RSA Algorithm
13 pages
Experiment 5
PDF
No ratings yet
Experiment 5
2 pages
Cycle2 Cns Record
PDF
No ratings yet
Cycle2 Cns Record
11 pages
RSA-1
PDF
No ratings yet
RSA-1
3 pages
RSA Encryption in Java
PDF
No ratings yet
RSA Encryption in Java
5 pages
RSA Encryption and Decryption:: Experiment 6 Aim
PDF
No ratings yet
RSA Encryption and Decryption:: Experiment 6 Aim
8 pages
D Haru Digital
PDF
No ratings yet
D Haru Digital
5 pages
4th RSA algorithm to encrypt and decrypt the data
PDF
No ratings yet
4th RSA algorithm to encrypt and decrypt the data
6 pages
CSS Experiment No. 5
PDF
No ratings yet
CSS Experiment No. 5
5 pages
Cns
PDF
No ratings yet
Cns
15 pages
NS Lab
PDF
No ratings yet
NS Lab
42 pages
Copy of INS 3,4,5,6,7,8,9
PDF
No ratings yet
Copy of INS 3,4,5,6,7,8,9
26 pages
CN Op
PDF
No ratings yet
CN Op
26 pages
Network Security Assignment No 4 RSA Implementation Group Members
PDF
No ratings yet
Network Security Assignment No 4 RSA Implementation Group Members
4 pages
labda3
PDF
No ratings yet
labda3
13 pages
ankur crypto 4
PDF
No ratings yet
ankur crypto 4
9 pages
NSLab
PDF
No ratings yet
NSLab
11 pages
css2
PDF
No ratings yet
css2
3 pages
DES
PDF
No ratings yet
DES
15 pages
DATA ENCRYPTION STANDARD
PDF
No ratings yet
DATA ENCRYPTION STANDARD
9 pages
Seed Code For Project 1 - Secure Client-Server Communication Using RSA Algorithm
PDF
No ratings yet
Seed Code For Project 1 - Secure Client-Server Communication Using RSA Algorithm
4 pages
Practical Exam
PDF
No ratings yet
Practical Exam
25 pages
NIS MicroProject ISHA
PDF
No ratings yet
NIS MicroProject ISHA
22 pages
Assignment 4
PDF
No ratings yet
Assignment 4
3 pages
CRYPTOGRAPHY AND NETWORK SECURITY LAB4
PDF
No ratings yet
CRYPTOGRAPHY AND NETWORK SECURITY LAB4
9 pages
RSAalgorithm
PDF
No ratings yet
RSAalgorithm
3 pages
An Implementation of RSA and ElGamal PKCs Using Java BigInteger Class
PDF
No ratings yet
An Implementation of RSA and ElGamal PKCs Using Java BigInteger Class
20 pages
Rsa
PDF
No ratings yet
Rsa
3 pages
practical_8_is_tikeshwar_d2_59
PDF
No ratings yet
practical_8_is_tikeshwar_d2_59
4 pages
Crypto DA
PDF
No ratings yet
Crypto DA
9 pages
RSA Implementation W/ Java: Greg Macko
PDF
No ratings yet
RSA Implementation W/ Java: Greg Macko
13 pages
Ccs354 Ns Lab Final
PDF
No ratings yet
Ccs354 Ns Lab Final
43 pages
Lab Program 11
PDF
No ratings yet
Lab Program 11
3 pages
Experiment-8: To Implement RSA Encryption-Decryption
PDF
No ratings yet
Experiment-8: To Implement RSA Encryption-Decryption
5 pages
CNS Observation 6 Programs
PDF
No ratings yet
CNS Observation 6 Programs
12 pages
exp3
PDF
No ratings yet
exp3
6 pages
Network Security Lab Manual
PDF
No ratings yet
Network Security Lab Manual
35 pages
Ans Lab Record
PDF
100% (3)
Ans Lab Record
26 pages
IS ASSIGNMENT 02
PDF
No ratings yet
IS ASSIGNMENT 02
5 pages
12 Implementation of RSA Algorithm
PDF
No ratings yet
12 Implementation of RSA Algorithm
4 pages
CSS 1 and 2
PDF
No ratings yet
CSS 1 and 2
8 pages
1 To 3
PDF
No ratings yet
1 To 3
15 pages
Sample Java Code For RSA Encryption and Decryption
PDF
100% (1)
Sample Java Code For RSA Encryption and Decryption
2 pages
14 Applications of Number Theory
PDF
No ratings yet
14 Applications of Number Theory
42 pages
14 Applications of Number Theory
PDF
No ratings yet
14 Applications of Number Theory
42 pages
CNS
PDF
No ratings yet
CNS
11 pages