servelt -jsp Encryption Decryption Code

servelt -jsp Encryption Decryption Code

Encryption code&Decryption code Iam developing a web security application for that reason i need a code of encryption &Decryption in servlet. Can u please send it to me.Its very urgent Because my project delivery date is very near

View Answers

February 15, 2011 at 10:49 AM

import java.io.*;
import java.security.*;
import javax.crypto.*;

class EncryptAndDecrypt {

public static void main (String[] args) throws Exception{
KeyPairGenerator keygenerator = KeyPairGenerator.getInstance("RSA");
SecureRandom random = SecureRandom.getInstance("SHA1PRNG", "SUN");
keygenerator.initialize(1024, random);

KeyPair keypair = keygenerator.generateKeyPair();
PrivateKey privateKey = keypair.getPrivate();
PublicKey publicKey = keypair.getPublic();
Cipher cipher = Cipher.getInstance("RSA");

cipher.init(Cipher.ENCRYPT_MODE, publicKey);
String st= "roseindia";
byte[] cleartext = null;
cleartext = st.getBytes();
byte[] ciphertext = null;
ciphertext = cipher.doFinal(cleartext);
System.out.println("the encrypted text is: " + ciphertext.toString());

cipher.init(Cipher.DECRYPT_MODE, privateKey);
byte[] cleartext1 = cipher.doFinal(ciphertext);
System.out.println("the decrypted cleartext is: " + new String(cleartext1));
}
}

make a package and import it into servlet or write this code in servlet directly also take care have a nice day

Ads









Related Tutorials/Questions & Answers:
Sample code for An ASCII Encryption and Decryption code in C-language only.
Sample code for An ASCII Encryption and Decryption code in C-language only... code for this project including both the encryption and decryption aspects... stored in a file. This is called encryption. When one wants to read the contents
encryption and decryption of files
encryption and decryption of files   Please can any one provide me with the code for encryption and decryption of files using RSA algorithm. I want to use a browse option to search for the file which is needed for encryption
Advertisements
encryption and decryption
encryption and decryption  how to encrypt and decrypt data in text file
encryption and decryption
encryption and decryption   ASCII encryptor I want to develop a program that encrypt and decrypt. The messages stored in a file should.... This is called encryption. When one wants to read the contents of the file
encryption and decryption
encryption and decryption   ASCII encryptor I want to develop a program that encrypt and decrypt. The messages stored in a file should.... This is called encryption. When one wants to read the contents of the file
encryption and decryption
encryption and decryption   ASCII encryptor I want to develop a program that encrypt and decrypt. The messages stored in a file should.... This is called encryption. When one wants to read the contents of the file
encryption and decryption
encryption and decryption   ASCII encryptor I want to develop a program that encrypt and decrypt. The messages stored in a file should.... This is called encryption. When one wants to read the contents of the file
Encryption Decryption In Scriptlets/Java
Encryption Decryption In Scriptlets/Java  I have this code in my scriptlet, when I use the Encryption code to encrypt my data it executes... where the program stopped working and it stopped in the decryption part and I get
Encryption Decryption
Encryption Decryption  I want to store a type string to my database... want to retrieve it in it's decrypted format. I am using JSP's, I want to encrypt user input on one jsp and retrieve it, decrypted, on another jsp for viewing
Password encryption and decryption
Password encryption and decryption  Hello, I'm developing a system... then you can use the decrypt function, created in the jsp. 1)form.jsp: <...; For the above code, we have create a database table: CREATE TABLE `user
stegnography code
stegnography code  code for the digital stegnographic technique for the encryption and decryption of image
servelt refresh page
servelt refresh page   write a program in servlet that display the cricket score.the page should automatically refresh on every 5 seconds.the score should add on every refresh.the total over is 5.on every 30 seconds the wicket
AES decryption in Java
AES decryption in Java   AES decryption in Java with password...-Decryption-using-key-password-.html    http://www.roseindia.net/answers/viewqa/Java-Beginners/26020-AES-Decryption-using-key-password-.html   
sound encryption
sound encryption  i want to ask if there is a simple code to perform encryption on sound file
AES encryption in J2ME
AES encryption in J2ME  Is it possible to do aes encryption in j2me
ModuleNotFoundError: No module named 'Encryption'
ModuleNotFoundError: No module named 'Encryption'  Hi, My Python... 'Encryption' How to remove the ModuleNotFoundError: No module named 'Encryption' error? Thanks   Hi, In your python environment you
AES Decryption using key password
AES Decryption using key password    /* Decrypt using AES with password */ /* developed by Nishanth Thomas - Insolutions Global Pvt Ltd Bangalore */ import java.security.spec.AlgorithmParameterSpec; import
Maven Dependency encryption >> 2.0.0
You should include the dependency code given in this page to add Maven Dependency of com.braintreepayments >> encryption version2.0.0 in your project
Maven Dependency encryption >> 2.1.0
You should include the dependency code given in this page to add Maven Dependency of com.braintreepayments >> encryption version2.1.0 in your project
Version of com.braintreepayments>encryption dependency
List of Version of com.braintreepayments>encryption dependency
ModuleNotFoundError: No module named 'aws-encryption'
ModuleNotFoundError: No module named 'aws-encryption'  Hi, My... named 'aws-encryption' How to remove the ModuleNotFoundError: No module named 'aws-encryption' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'aws-encryption'
ModuleNotFoundError: No module named 'aws-encryption'  Hi, My... named 'aws-encryption' How to remove the ModuleNotFoundError: No module named 'aws-encryption' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'aws-encryption'
ModuleNotFoundError: No module named 'aws-encryption'  Hi, My... named 'aws-encryption' How to remove the ModuleNotFoundError: No module named 'aws-encryption' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'cred-encryption'
ModuleNotFoundError: No module named 'cred-encryption'  Hi, My... named 'cred-encryption' How to remove the ModuleNotFoundError: No module named 'cred-encryption' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'cred-encryption'
ModuleNotFoundError: No module named 'cred-encryption'  Hi, My... named 'cred-encryption' How to remove the ModuleNotFoundError: No module named 'cred-encryption' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'cred-encryption'
ModuleNotFoundError: No module named 'cred-encryption'  Hi, My... named 'cred-encryption' How to remove the ModuleNotFoundError: No module named 'cred-encryption' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'dynamodb-encryption'
ModuleNotFoundError: No module named 'dynamodb-encryption'  Hi, My... named 'dynamodb-encryption' How to remove the ModuleNotFoundError: No module named 'dynamodb-encryption' error? Thanks   Hi
ModuleNotFoundError: No module named 'dynamodb-encryption'
ModuleNotFoundError: No module named 'dynamodb-encryption'  Hi, My... named 'dynamodb-encryption' How to remove the ModuleNotFoundError: No module named 'dynamodb-encryption' error? Thanks   Hi
ModuleNotFoundError: No module named 'py-encryption'
ModuleNotFoundError: No module named 'py-encryption'  Hi, My... 'py-encryption' How to remove the ModuleNotFoundError: No module named 'py-encryption' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'ska-encryption'
ModuleNotFoundError: No module named 'ska-encryption'  Hi, My... named 'ska-encryption' How to remove the ModuleNotFoundError: No module named 'ska-encryption' error? Thanks   Hi, In your python
Code
Code  code for connecting c lang to database

Ads