How to write a rsa algorithm using thread
Hi...
This my **rsa algorithm sequential code..can u anyone plz change/convert to concurrent java or parallel this code..
print("code sample");
import java.security.KeyPairGenerator;
import java.security.KeyPair;
import java.security.PublicKey;
import java.security.PrivateKey;
import javax.crypto.Cipher;
public class rsa {
private static byte[] encrypt(byte[] inpBytes, PublicKey key,
String xform) throws Exception {
Cipher cipher = Cipher.getInstance(xform);
cipher.init(Cipher.ENCRYPT_MODE, key);
return cipher.doFinal(inpBytes);
}
private static byte[] decrypt(byte[] inpBytes, PrivateKey key,
String xform) throws Exception{
Cipher cipher = Cipher.getInstance(xform);
cipher.init(Cipher.DECRYPT_MODE, key);
return cipher.doFinal(inpBytes);
}
public static void main(String[] unused) throws Exception {
long starttime =System.currentTimeMillis();
String xform = "RSA/NONE/PKCS1PADDING";
// Generate a key-pair
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(1024); // 1024 is the keysize.
KeyPair kp = kpg.generateKeyPair();
PublicKey pubk = kp.getPublic();
PrivateKey prvk = kp.getPrivate();
byte[] dataBytes =
"J2EE Security for Servlets, EJBs and Web Services".getBytes();
byte[] encBytes = encrypt(dataBytes, pubk, xform);
System.out.println(encBytes);
byte[] decBytes = decrypt(encBytes, prvk, xform);
System.out.println(decBytes);
String res=new String(decBytes);
boolean expected = java.util.Arrays.equals(dataBytes, decBytes);
System.out.println("Test " + (expected ? "SUCCEEDED!" : "FAILED!"));
System.out.println(res);
long endtime=System.currentTimeMillis();
System.out.println("Time required for sequential rsa algorithm:"+(endtime-starttime)+"millisecond");
}
}
THANKS
LAVANYA
View Answers
Related Tutorials/Questions & Answers:
How to write a rsa algorithm using threadHow to
write a
rsa algorithm using thread Hi...
This my **
rsa algorithm sequential code..can u anyone plz change/convert to concurrent...();
System.out.println("Time required for sequential
rsa algorithm:"+(endtime-starttime
Advertisements
How to write to file using FileOutputStreamHow to
write to file
using FileOutputStream Hi friends,
Please help me in java program.
How to
write to file
using FileOutputStream?
thanks,
Hi,
To
write a file
using FileOutputStream, we have to use
How to write to file using FileWriterHow to
write to file
using FileWriter hi,
How to
write to file
using FileWriter
thanks,
Hi,
To writing in a file in Java program we... of the FileWriter class can be created
using the following of its constructor i.e. FileWriter
How to Explain different way of using thread?How to Explain different way of
using thread? Hi,
How to explain
how to
using different
thread in Java program........
Hi,
There are different types
Thread in Java program. Here is the explain
how to
using thread how to write a jsp form using htmlhow to
write a jsp form
using html hi,
i have written the code as below... but it is showing error. please help me
how to resolve it.
.html file
<html>
<head><title>StudentForm</title></head>
CREATE AND WRITE FILE THREAD JAVACREATE AND
WRITE FILE
THREAD JAVA Hi guys I was wondering
how can I make this program in java with threads.
I need to create a file and
write in it (i know
how to do that) but by listening in some port all the data that is being
algorithmalgorithm Hi all,
i have a task which is create an
algorithm from... on this matter...
thanks a lot.
here is my
algorithm:
>
Input... for
end for each
end while
//
write candidates into final test set
algorithmalgorithm convert this
algorithm to java code
IsSample_PAS:
1.for every attribute value aj belongs to ti do begin
(here aj=1,2...,ti=1,2..)
2.if(CF... false;
(this is
algorithm from ieee paper QUALITY AWARE SAMPLING AND ITS
AlgorithmAlgorithm
How can i
write a code for sort ascending order to ten given numbers.
Thank you
Receive the numbers into an array.
double num[10]. or int num[10].ADS_TO_REPLACE_1
You then need to traverse the array
ModuleNotFoundError: No module named 'rsa'ModuleNotFoundError: No module named '
rsa' Hi,
My Python program is throwing following error:
ModuleNotFoundError: No module named '
rsa'
How to remove the ModuleNotFoundError: No module named '
rsa' error
Asymmetric algorithm - Java BeginnersAsymmetric algorithm hybrid Digital image embedding
using invisible watermarking with
rsa and dct
algorithm?
please send me this project with source code........
regards
subramanian
Algorithm - Java3DAlgorithm what is NaiveSimilarity
algorithm?
How we use this
algorithm to recognize a face in face recognition (
using Java)?
which is the steps involved in this?
Which is the database used to store an image
ModuleNotFoundError: No module named 'pyjsbn-rsa' 'pyjsbn-
rsa'
How to remove the ModuleNotFoundError: No module named 'pyjsbn-
rsa' error?
Thanks
Hi,
In your python environment you...ModuleNotFoundError: No module named 'pyjsbn-
rsa' Hi,
My Python
ModuleNotFoundError: No module named 'pyjwt-rsa' 'pyjwt-
rsa'
How to remove the ModuleNotFoundError: No module named 'pyjwt-
rsa' error?
Thanks
Hi,
In your python environment you...ModuleNotFoundError: No module named 'pyjwt-
rsa' Hi,
My Python
ModuleNotFoundError: No module named 'rsa-archer' '
rsa-archer'
How to remove the ModuleNotFoundError: No module named '
rsa...ModuleNotFoundError: No module named '
rsa-archer' Hi,
My Python... have to install padas library.
You can install
rsa-archer python
ModuleNotFoundError: No module named 'RSA-Cipher' '
RSA-Cipher'
How to remove the ModuleNotFoundError: No module named '
RSA...ModuleNotFoundError: No module named '
RSA-Cipher' Hi,
My Python... have to install padas library.
You can install
RSA-Cipher python
ModuleNotFoundError: No module named 'RSA_Tools' '
RSA_Tools'
How to remove the ModuleNotFoundError: No module named '
RSA...ModuleNotFoundError: No module named '
RSA_Tools' Hi,
My Python... have to install padas library.
You can install
RSA_Tools python with following
ModuleNotFoundError: No module named 'simple-rsa' 'simple-
rsa'
How to remove the ModuleNotFoundError: No module named 'simple-
rsa' error?
Thanks
Hi,
In your python environment you...ModuleNotFoundError: No module named 'simple-
rsa' Hi,
My Python
ModuleNotFoundError: No module named 'tiny-rsa' 'tiny-
rsa'
How to remove the ModuleNotFoundError: No module named 'tiny-
rsa...ModuleNotFoundError: No module named 'tiny-
rsa' Hi,
My Python... to install padas library.
You can install tiny-
rsa python with following
ModuleNotFoundError: No module named 'tiny-rsa' 'tiny-
rsa'
How to remove the ModuleNotFoundError: No module named 'tiny-
rsa...ModuleNotFoundError: No module named 'tiny-
rsa' Hi,
My Python... to install padas library.
You can install tiny-
rsa python with following
ModuleNotFoundError: No module named 'Cyber-RSA' 'Cyber-
RSA'
How to remove the ModuleNotFoundError: No module named 'Cyber-
RSA' error?
Thanks
Hi,
In your python environment you...ModuleNotFoundError: No module named 'Cyber-
RSA' Hi,
My Python
ModuleNotFoundError: No module named 'fusion-rsa' 'fusion-
rsa'
How to remove the ModuleNotFoundError: No module named 'fusion-
rsa' error?
Thanks
Hi,
In your python environment you...ModuleNotFoundError: No module named 'fusion-
rsa' Hi,
My Python
How to write in File in JavaHow to
write in File in Java Hi,
How to
write in File in Java... bufferedWriter object to
write in the file.
For more details and examples related to
How... and custructor. To open some file we require it to be open in append mode by
using How to write in File in JavaHow to
write in File in Java Hi,
How to
write in File in Java. Please suggest and give example of this program.
thanks
How to write a file in Java?How to
write a file in Java? To
write a file in Java use the class FileWriter and BufferedWriter.
Class FileWriter:
The FileWriter class is used to
write... and strings.
Example of
how to
write text to a file in java:ADS_TO_REPLACE_6
import