Home Answers Viewqa Java-Beginners How to write a rsa algorithm using thread

 
 


lavanya
How to write a rsa algorithm using thread
0 Answer(s)      2 years and 2 months ago
Posted in : Java Beginners

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 Pages:
How to write a rsa algorithm using thread
How to write a rsa algorithm using thread   Hi... This my **rsa algorithm sequential code..can u anyone plz change/convert to concurrent...("Time required for sequential rsa algorithm:"+(endtime-starttime)+"millisecond
Algorithm
Algorithm  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]. You then need to traverse the array elements and swap
Spring application in RSA 7.0.0.3
Spring application in RSA 7.0.0.3  how to build a sample spring application using RSA 7.0.0.3
Algorithm - Java3D
Algorithm  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
algorithm
algorithm  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
Asymmetric algorithm - Java Beginners
Asymmetric algorithm  hybrid Digital image embedding using invisible watermarking with rsa and dct algorithm? please send me this project with source code........ regards subramanian
implementing an algorithm using multi threads - Java Beginners
implementing an algorithm using multi threads  Hi i need to implement... data from one thread to another thread. I am posting my algorithm which needs...; double d=-6; double F=0.0; double lamsq=0.25; Thread t1 = new Thread
efficiency of an algorithm
efficiency of an algorithm  how can we calculate the best or worst case efficiency of an algorithm
efficiency of an algorithm
efficiency of an algorithm  how can we calculate the best or worst case efficiency of an algorithm
Conflation Algorithm
Conflation Algorithm  implementation of conflation algorithm is possible using java?? conflation requires file handling a text contains stop words(is,or,and,.,)remove this words remove suffix(ing,ed..) remove equal words count
CREATE AND WRITE FILE THREAD JAVA
CREATE 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
Write an applet to display scrolling image in an applet window using thread.
Write an applet to display scrolling image in an applet window using thread.  Write an applet to display scrolling image in an applet window using thread
Thread Priorities
a thread's priority at any time after its creation using the setPriority method. Lets see, how to set and get the priority of a thread.   class MyThread1... Thread Priorities     
Thread Priorities
its creation using the setPriority method. Lets see, how to set and get... Thread Priorities         In Java, thread scheduler can use the thread
Thread Priorities
its creation using the setPriority method. Lets see, how to set and get... Thread Priorities         In Java, thread scheduler can use the thread priorities
creating trafficsignal using thread
creating trafficsignal using thread  please give me code how to create trafic signal using thread and give me it to my email jvp_9040@ymail.com thanks
Problem analysis and algorithm design (i.e.: flowchart, algorithm)
Problem analysis and algorithm design (i.e.: flowchart, algorithm)  Problem analysis and algorithm design (i.e.: flowchart, algorithm... in a class. Then, prompt user to input the students programming mark. Determine how many
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
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 to file using FileOutputStream
How 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 FileWriter
How 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
Thread
Thread  Write a Java program to create three theads. Each thread should produce the sum of 1 to 10, 11 to 20 and 21to 30 respectively. Main thread....   Java Thread Example class ThreadExample{ static int
Thread priority in java
) algorithm. We can also set the priority of thread by using setPriority.... Example : A program how to set or get priority of thread in java. class...Thread priority in java A thread is a part or entity of a  process
algorithm
algorithm  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
how to read and write an xml file using java
how to read and write an xml file using java  Hi Can anyone help me how to read and write an xml file which has CData using java
how to write a program to search a record using mvc2
how to write a program to search a record using mvc2   how can we write a code to search a record in table by using java bean as model, servlet as contoller and jsp as view
How to write a search functionality using javascript/jquery
How to write a search functionality using javascript/jquery   How to write a search functionality using javascript/jquery for ex: im searching "s" names it wil display "s" names
Java Sleep Thread
Java Thread sleep() is a static method. It sleeps the thread for the given time in milliseconds. It is used to delay the thread. It is used in Applet or GUI programming for animation Java Sleep Thread Example public class
Java :Thread getPriority Example
Java :Thread getPriority Example In this tutorial you will learn how to get thread priority in java thread. Thread getPriority() : Thread scheduler uses thread priority concept to assign priority to the thread. A higher priority 
read and write a file using javascript
read and write a file using javascript  How to read and write a file using javascript
How to write in File in Java
How 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
Java :Thread setPriority Example
Java :Thread setPriority Example In this tutorial you will learn how to set thread priority in java thread. Thread setPriority() : Thread scheduler uses thread priority concept to assign priority to the thread. A higher priority 
How to write image in Jmagick
How to write image in Jmagick  hi, I am new in Java I am using the Jmagick library, how can I write an image in Jmagick ? Thanks.   hi, You can try this snippet into your code ImageInfo ii = new ImageInfo("abc.jpg
How to write text on image
How to write text on image  hi, I am using the Jmagick library. I want to write text on image, how is it possible ? Thanks.   hi, I am new in Jmagick but, I used the following code and it might also help you
how to write this program
how to write this program  Write a program in java which calculates... or numerical grade. You will be submitting TWO versions of this program. Write one version using the scanner object input method and one using the input box input method
how to write a jsp form using html
how 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>
Inter Thread Communication
is how a thread outside the critical region can know that it can execute inside...Inter Thread Communication  what is inter thread communication?   hi friend, Inter thread communication is a process of communication
Java Thread checkAccess
Java Thread checkAccess In this tutorial you will learn how to check permission of thread modification by using checkAccess () method. Thread checkAccess... changes to the thread by using checkAccess() method. class CheckAccess
Java Thread : isAlive() method
Java Thread : isAlive() method In this tutorial you will learn how to use isAlive() method in java thread. isAlive() method : When you are running many... of your thread dead. This can be checked by using method Thread.isAlive(). boolean
how to write weighted moving average code using 2d-array
how to write weighted moving average code using 2d-array  how to write weighted moving average code using 2d-array
how to use Excel Templet to write excel file using java.
how to use Excel Templet to write excel file using java.  how to use Excel Templet to write excel file using java
how to use Excel Template to write excel file using java
how to use Excel Template to write excel file using java  How to use Excel template to write data in that file using java
how to write to file at the end of the line
how to write to file at the end of the line  Hi, Where do i learn how to write to file at the end of the line using Java program. Plz suggest... will help you for "How to write the file at the end of line using Java language
Java :Thread Join
Java :Thread Join In this tutorial you will see how to use join method in java thread. join() method - join method waits until the thread die. If we... nanoseconds for your thread to die. Example : In this tutorial we are using join
J2ME Thread Processing Example
J2ME Thread Processing Example       In the given example, you will learn about the thread and how... simultaneously using thread. Here we have defined different states of thread
how to write file from FileInputStream
how to write file from FileInputStream  Hi, How to Write a file.... Thanks,   Hi, For Write to file from FileInputStream in java you may use the FileInputStream class of java.io package. Using this class takes input
How to write file by line in Java
How to write file by line in Java  How to write file by line in Java   Hi, For Write to a file by line using java programming language we... in a new line. How to use Write To File By Line in Java programs
Java Thread Priorities
.style1 { font-size: medium; } Java Thread Priorities In this section, we will discuss how to set thread priorities with example. Thread... type is int. Example :In this example we are using thread priority methods
java thread - Java Beginners
Java Thread  What is thread in Java? and how can i write a Java thread program?Thanks in advance!!  Hi friend,import javax.swing.*;import...(a); } private JPanel canvas;}class Ball extends Thread { public Ball(JPanel
Thread scheduling
Thread scheduling  What is the algorithm used in Thread scheduling?  Java uses fixed-priority scheduling algorithms to decide which thread... algorithm called fixed-priority scheduling. This algorithm schedules threads

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.