Home Answers Viewqa Java-Beginners AES Decryption using key password

 
 


Nishanth Thomas
AES Decryption using key password
1 Answer(s)      a year ago
Posted in : Java Beginners

  /* Decrypt using AES with password */

   /* developed by Nishanth Thomas - Insolutions Global Pvt Ltd Bangalore */

  import java.security.spec.AlgorithmParameterSpec;
  import javax.crypto.Cipher;
  import javax.crypto.spec.IvParameterSpec;
  import javax.crypto.spec.SecretKeySpec;
  import sun.misc.BASE64Decoder;

    public class testDecrypt {

  /*  Mode = CipherMode.CBC,-( Cipher-block chaining)
    Padding = PaddingMode.PKCS7 or PKCS5,
    KeySize = 128,
    BlockSize = 128,
    Key = keyBytes,
    IV = keyBytes */

     Cipher cipher; 

    // Input encrypted String
    static  String input = "sw0SrUIKe0DmS7sRd9+XMgtYg+BUiAfiOsdMw/Lo2RA=";

   // password to decrypt 16 bit
    final static String strPassword = "password12345678";

   // put this as key in AES
   static SecretKeySpec key = new SecretKeySpec(strPassword.getBytes(), "AES");


   public static void main(String args []) throws Exception{

    AlgorithmParameterSpec paramSpec = new IvParameterSpec(strPassword.getBytes()); 
    //Whatever you want to encrypt/decrypt using AES /CBC padding
    Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");

    //You can use ENCRYPT_MODE or DECRYPT_MODE 
     cipher.init(Cipher.DECRYPT_MODE, key, paramSpec);  

     //decode data using standard decoder
     byte[] output =  new BASE64Decoder().decodeBuffer(input);  

       // Decrypt the data 
     byte[] decrypted = cipher.doFinal(output);

     System.out.println("Original string: " +
             new String(input));

     // decryptedData .;
     System.out.println("Decrypted string: " +
     new String(decrypted));    

   }

 }
View Answers

May 22, 2012 at 11:26 AM


  /* Decrypt using AES with password */

     /* developed by Nishanth Thomas - Insolutions Global  Pvt Ltd Bangalore */

 import java.security.spec.AlgorithmParameterSpec;
 import javax.crypto.Cipher;
 import javax.crypto.spec.IvParameterSpec;
 import javax.crypto.spec.SecretKeySpec;
 import sun.misc.BASE64Decoder;

  public class testDecrypt {

 /*  Mode = CipherMode.CBC,-( Cipher-block chaining)
  Padding = PaddingMode.PKCS7 or PKCS5,
  KeySize = 128,
  BlockSize = 128,
  Key = keyBytes,
  IV = keyBytes */

   Cipher cipher; 

  // Input encrypted String
  static  String input = "sw0SrUIKe0DmS7sRd9+XMgtYg+BUiAfiOsdMw/Lo2RA=";

 // password to decrypt 16 bit
  final static String strPassword = "password12345678";

 // put this as key in AES
 static SecretKeySpec key = new SecretKeySpec(strPassword.getBytes(), "AES");


 public static void main(String args []) throws Exception{

  AlgorithmParameterSpec paramSpec = new IvParameterSpec(strPassword.getBytes()); 
  //Whatever you want to encrypt/decrypt using AES /CBC padding
  Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");

  //You can use ENCRYPT_MODE or DECRYPT_MODE 
 cipher.init(Cipher.DECRYPT_MODE, key, paramSpec);  

   //decode data using standard decoder
   byte[] output =  new BASE64Decoder().decodeBuffer(input);  

     // Decrypt the data 
  byte[] decrypted = cipher.doFinal(output);

   System.out.println("Original string: " +
         new String(input));

   // decryptedData .;
   System.out.println("Decrypted string: " +
 new String(decrypted));    

 }

}









Related Pages:
AES Decryption using key password
AES Decryption using key password    /* Decrypt using AES...;  /* Decrypt using AES with password */ /* developed by Nishanth..."; // put this as key in AES static SecretKeySpec key = new SecretKeySpec
AES decryption in Java
-Decryption-using-key-password-.html    http://www.roseindia.net/answers/viewqa/Java-Beginners/26020-AES-Decryption-using-key-password-.html   ...AES decryption in Java   AES decryption in Java with password
Java Encryption using AES with key password
Java Encryption using AES with key password    /* AES alogrithm using password key */ /* developed by Nishanth Thomas Insolutions Global Pvt... */ /* AES alogrithm using password key */ /* developed by Nishanth Thomas
Password encryption and decryption
Password encryption and decryption  Hello, I'm developing a system... users' password in the database so that I wouldnt know their password. Is there anyway that you could teach me how to encrypt the password and store
Encryption and Decryption - Java Beginners
Encryption and Decryption  Hello sir, i need Password encryption and decryption program using java program. I dont know how to write the program... the source code of encyption and decryption using java. Thanking you... 
part of AES code in JSP
part of AES code in JSP  org.apache.jasper.JasperException: Unable to compile class for JSP An error occurred at line: 19 in the jsp file...; } } writer.println("Enter password:"); inp
Encryption Decryption
Encryption Decryption  I want to store a type string to my database, specifically MSSQL, I want the stored data in the database to be encrypted and I want to retrieve it in it's decrypted format. I am using JSP's, I want
Encryption Decryption In Scriptlets/Java
Encryption Decryption In Scriptlets/Java  I have this code in my... where the program stopped working and it stopped in the decryption part and I get... DESede key".getBytes(); DESedeKeySpec spec = new DESedeKeySpec(encryptKey
encryption and decryption - Java Beginners
encryption and decryption  i need files encryption and decryption program using java. but i dont know how to write the program.pls help me thank you so much  Hi Friend, Try the following code: import java.io.
Developing Forgot Password Form
Developing Forgot Password Form       In this section we will develop Forgot Password Form code for our application. Developing Forgot Password Form  
AES encryption in J2ME
AES encryption in J2ME  Is it possible to do aes encryption in j2me
Softabar Password Manager
, is encrypted using AES encryption algorithm. Store accounts to server using Softabar Password Manager Server Storage... Softabar Password Manager   
forget password
forget password  codding for forget password using spring framework
forget password?
forget password?  can anyone help me? how to create a module of forget password?the password can reset by generate random password and send to user's email..i develop the php system using xampp and dreamweaver
forget password?
forget password?  can anyone help me? how to create a module of forget password?the password can reset by generate random password and send to user's email..i develop the php system using xampp and dreamweaver
password change
password change  Hi , I am using jsf and trying to write a code to change the password of a user . Ihave to retrine userid fromdata base how to do that using session
forget password
forget password  can i get coding for forgot password in jsp, need using javamail also cannot.. what should i do?? Thx
encrypt the username and password using PHP
encrypt the username and password using PHP  How can we encrypt the username and password using PHP?   Hi friends, You can use the MySQL PASSWORD() function to encrypt username and password. For example, INSERT
Create primary key using hibernate
Create primary key using hibernate  How to create primary key using hibernate?   The id element describes the primary key for the persistent class and how the key value is generated.   <id name="id
password validation with special character
password validation with special character  how to validate password with special character using java script
How to create primary key using hibernate?
How to create primary key using hibernate?  Hi, How to create primary key using hibernate? Thanks
Password History - JSP-Servlet
Password History  I am using servlets and in my application i want to maintain password history.It means on password change My application should check previous 5 password so that new password can't be same to 5 old password
change password - JSP-Servlet
a simple web application using mysql and jsp. now i want to create a web page for a user. this web page consists of changing the password for the existing user. it look like this: current password new password confirm new password SUBMIT
Random Creation of password
details in it.When clicking on the submit button it gives me a password .....Details and the password is saved in the database....The password has to be encrypted and then send to the database.....I am using jsp as my front end and java
Authentication of password - Swing AWT
Authentication of password  System level authentication of password.... How the Printed password gets converted into the asteric (*) mark... static Key genkey = null; private static Cipher cipher = null
Foreign key in mysql
Foreign key in mysql  Hi I am creating a website and linking it to a database using php and mysql. I need to create the databases in phpmyadmin... the foreign key of one table into another table within phpmyadmin so the database
Password - Java Beginners
Password  I neeed a program to type a prssword and echo some other charecter just as typing password in E-mail.ID without using applet... can we do... = Box.createHorizontalBox(); rowTwo.add(new JLabel("Password")); rowTwo.add(new
hibernate Foreign key
using set methods in orders table in feild P_Id which is foreign key. How to insert...hibernate Foreign key  sir, I am using hibernate in netbeans. I have...(255) DEFAULT NULL, City varchar(255) DEFAULT NULL, PRIMARY KEY (P_Id
Forgot Password Screen of Application
Forgot Password Screen of Application       Forgot Password Screen our web application allows the user, to request for their forgotten password. Program sends the password
Password
Password  make a program which ask ask the username and password * in this format. in C language
decryption and encryption - Java Beginners
decryption and encryption  hi everyone. my question is that i have one problem which i have to solve and the issue is that i have to do the encryption and decryption thing there in my code, e.g if the user enters the abc the code
composinte primary key in hibernate
composinte primary key in hibernate  I am facing following problem, Inside the database(mssql), i have created a table without primary key... primary key with all the columns of the table and hibernate s/w has created two pojo
Java Read username, password and port from properties file
Java Read username, password and port from properties file In this section, you will come to know how to read username, password and port no from... to a stream or loaded from a stream using the properties file
jQuery password validation
jQuery password Validation : jQuery "equalTo: "#password" " is the method to validate or check password if the element is empty (text input) or  unequal  password type entered. With the help of this password
can any one give the frogort password code using jsp,
can any one give the frogort password code using jsp,  plz give the code for frogot password
JavaScript Key Event
by using the onkeyup event. It occurs when a keyboard key is released. Following... on the text field2 on key up. For this purpose, we have created two text fields text1 and text2. On pressing the key to write the text on the textbox1, you
How can we encrypt the username and password using PHP?
How can we encrypt the username and password using PHP?  How can we encrypt the username and password using PHP
J2ME Key Codes Example
J2ME Key Codes Example       This application illustrates how to print the key value with the current key pressed on the canvas. In this application we are using the keyPressed
Missing message for key tenant.lbl - Struts
Missing message for key tenant.lbl  I have properties file with key value pair.I am trying to get that value int jsp by using tag.In struts-config.xml I placed below code still I am getting Missing message for key tenant.lbl.
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
Password Controls
; <head> <title>Using Password Controls</title> <...Password Controls      ... determines whether the password entered by the user is correct or not. This whole
Struts2.2.1 password tag example.
; <s:password name="password" key="...Struts2.2.1 password tag example. In this tutorial, you will see the use of password tag of struts2.2.1. It is a  UI tag in struts framework. It display
Change root password of MYSQL using Java
Change root password of MYSQL using Java In this tutorial, you will learn how to change the root password of MYSQL database using java code. For every..., the system administrator user is called root. You can also set the new password using
how tohow to create a table with primary key and foreign keyhow to create a table with primary key and foreign key
how tohow to create a table with primary key and foreign keyhow to create a table with primary key and foreign key  how to create a table using java language with primary key and foreign key   Hi Friend, A foreign

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.