Hi Mark
Nice to hear the Immediate Reply.Thanks...
But
I am doing the simple program to encrypt and decrypt the string.but while i compiling i am getting these errors.
Program :-
import javax.crypto.cipher;
import javax.crypto.KeyGenerator;
import java.security.Key;
import java.security.Security;
import java.security.NoSuchAlgorithmException;
import java.security.InvalidKeyEception;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.BadPaddingException;
public class encryptTest
{
public static void main(String args[])
{
String password = "HelloWorld";
try
{
KeyGenerator kg = KeyGenerator.getInstance("DES");
Key key = kg.generateKey();
Cipher cipher = Cipher.getInstance("DES");
byte[] plain_password = password.getBytes();
String str_plain_password = new String(plain_password);
System.out.println("Plain Password = " + str_plain_password);
cipher.init(Cipher.ENCRYPT_MODE,key);
byte[] encrypted_password = cipher.doFinal(plain_password);
String str_encrypted_password = new String(encrypted_password);
System.out.println("Encrypted Password = " + str_encrypted_password);
cipher.init(Cipher.DECRYPT_CODE,key);
byte[] decrypted_password = cipher.doFinal(encrypted_password);
String str_decrypted_password = new String(decrypted_password);
System.out.println("Decrypted Password = " + str_decrypted_password);
}
catch(NoSuchAlgorithmException nsae)
{
System.out.println("No Such Algorithm Exception " + nsae.getMessage());
}
catch(NoSuchPaddingException nspe)
{
System.out.println("No Such Padding Exception " + nspe.getMessage());
}
catch(InvalidKeyException ike)
{
System.out.println("Invalid Key Exception " + ike.getMessage());
}
catch(
IllegalStateException ise)
{
System.out.println("Illegal State Exception " + ise.getMessage());
}
catch(IllegalBlockSizeException ibse)
{
System.out.println("Illegal Block Size Exception " + ibse.getMessage());
}
catch(BadPaddingException bpe)
{
System.out.println("Bad Padding Exception " + bpe.getMessage());
}
}
}
Error :- import javax.crypto.cipher; ^ encryptTest.java:2: Class javax.crypto.KeyGenerator not found in import.
import javax.crypto.KeyGenerator; ^ encryptTest.java:6: Class java.security.InvalidKeyEception not found in import.
import java.security.InvalidKeyEception; ^ encryptTest.java:7: Class javax.crypto.NoSuchPaddingException not found in import.
import javax.crypto.NoSuchPaddingException; ^ encryptTest.java:8: Class javax.crypto.IllegalBlockSizeException not found in import.
import javax.crypto.IllegalBlockSizeException; ^ encryptTest.java:9: Class javax.crypto.BadPaddingException not found in import.
import javax.crypto.BadPaddingException;
I think this is mainly because of ClassPath problem.Can you please tell me what i need to do to rectify this error?
Thanks
Kumaar.S
[ January 27, 2003: Message edited by: Kumaran Sowrirajan ]