Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners AES Decryption using key password

Have Programming Question? Ask it here!
 
 
 


Nishanth Thomas
AES Decryption using key password
1 Answer(s)      2 years and 2 months 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));    

   }

 }

Advertisement
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 Tutorials/Questions & Answers:
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
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
Advertisements
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
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
AES encryption in J2ME
AES encryption in J2ME  Is it possible to do aes encryption in j2me
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
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
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
How to create primary key using hibernate?
How to create primary key using hibernate?  Hi, How to create primary key using hibernate? Thanks
code for password strength using jsp-servlet
code for password strength using jsp-servlet  hi.............. plz help me to give code for password strength using jsp-servlet for implementation in my project as soon as possible because i want to show this functionality in my
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
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
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.
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
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
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
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
how to check username & password from database using jsp
how to check username & password from database using jsp  Hello, I have created 1 html page which contain username, password & submit button. in my oracle10G database already contain table name admin which has name, password
Connect a linux machine from linux using java program without password
Connect a linux machine from linux using java program without password  Connect a linux machine from linux using java program without password. Can anyone help me
Access denied for user 'abc'@'xxxx' (using password: YES)
Access denied for user 'abc'@'xxxx' (using password: YES)  I have tested my code on local machine DB, its working correctly.. But when i shifted it to server DB using URL, Username and password.. i got this error .. How can i
Looking for change password in iphone application sdk using sqlite
Looking for change password in iphone application sdk using sqlite  i am trying to change old password in my iphone application my code is below...) == SQLITE_OK) { NSString *querySQL = [NSString stringWithFormat: @"SELECT password
How to handle the text using Key Listener Interface
How to handle the text using Key Listener Interface... to handle the text using the key events on the Java Awt component. All the key events... are going to show you how to display the text of textField1 on the text field2 on key
How to set a microsoft word document PASSWORD by using Visual Basic 2008 express?
How to set a microsoft word document PASSWORD by using Visual Basic 2008 express?   How to set a microsoft word document PASSWORD by using Visual Basic 2008 express
forget password
forget password  codding for forget password using spring framework
simple code to write an read and write the login detail to a xml file using javascript ( username and password )
simple code to write an read and write the login detail to a xml file using javascript ( username and password )  pls can nyone give me a code to write and read the login details (username and password )into a xml file using
primary key and unique key
primary key and unique key  Whats is mean by primary key and unique key
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
primary key and unique key
primary key and unique key  hello, What's the difference between a primary key and a unique key?   hii, Unique key: column restricts entry of duplicate values but entry of null values is allowed. Primary key
Define candidate key, alternate key, composite key.
Define candidate key, alternate key, composite key.  Define candidate key, alternate key, composite key
forget password
forget password  can i get coding for forgot password in jsp, need using javamail also cannot.. what should i do?? Thx
create webpage with table sql database using netbeans 6.8 with struts complete tutorial.(include username and password)
create webpage with table sql database using netbeans 6.8 with struts complete tutorial.(include username and password)   myself muthu,am working... webpage using java&j2ee.that webpage contain a home,carriers,contactus,about
forgot password?
forgot password?  forgot password
foget password
is user login ,second is new user and third is forget password in java using netbeans.so please help me to write the code for forget password button.forget password form have three field that is userid ,security question and answer of those
password check
password check  how to check sighup passowrd and login password
change password
change password  how to change password in the login form.... by giving options to user like this old password, new password.. pls help
retype password
retype password  coding for retype password
Reset Password
Reset Password  coding for reset password
create webpage with table sql database using netbeans 6.8 with struts complete tutorial.(include username and password) 0 Answer(s)
create webpage with table sql database using netbeans 6.8 with struts complete tutorial.(include username and password) 0 Answer(s)  create webpage with table sql database using netbeans 6.8 with struts complete tutorial.(include
 

 

 

DMCA.com