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 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 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
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. ADS_TO_REPLACE_1   
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 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... 
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
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
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
AES encryption in J2ME
AES encryption in J2ME  Is it possible to do aes encryption in j2me
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
Password
Password  make a program which ask ask the username and password * in this format. in C language
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 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
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
ModuleNotFoundError: No module named 'aes'
ModuleNotFoundError: No module named 'aes'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'aes' How to remove the ModuleNotFoundError: No module named 'aes' error
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.
Using Password Controls
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 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
Version of com.scottyab>aes-crypto dependency
List of Version of com.scottyab>aes-crypto dependency
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
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
ModuleNotFoundError: No module named 'aes-vial'
ModuleNotFoundError: No module named 'aes-vial'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'aes-vial' How to remove the ModuleNotFoundError: No module named 'aes-vial
ModuleNotFoundError: No module named 'aes-vial'
ModuleNotFoundError: No module named 'aes-vial'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'aes-vial' How to remove the ModuleNotFoundError: No module named 'aes-vial
ModuleNotFoundError: No module named 'alo-aes'
ModuleNotFoundError: No module named 'alo-aes'  Hi, My Python...-aes' How to remove the ModuleNotFoundError: No module named 'alo-aes... to install padas library. You can install alo-aes python with following command
ModuleNotFoundError: No module named 'simp-AES'
ModuleNotFoundError: No module named 'simp-AES'  Hi, My Python... 'simp-AES' How to remove the ModuleNotFoundError: No module named 'simp-AES... to install padas library. You can install simp-AES python with following
ModuleNotFoundError: No module named 'simple_aes'
ModuleNotFoundError: No module named 'simple_aes'  Hi, My Python... 'simple_aes' How to remove the ModuleNotFoundError: No module named 'simple_aes' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'unzip-aes'
ModuleNotFoundError: No module named 'unzip-aes'  Hi, My Python... 'unzip-aes' How to remove the ModuleNotFoundError: No module named 'unzip-aes' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'aes-encrypt'
ModuleNotFoundError: No module named 'aes-encrypt'  Hi, My Python... 'aes-encrypt' How to remove the ModuleNotFoundError: No module named 'aes-encrypt' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'aes-everywhere'
ModuleNotFoundError: No module named 'aes-everywhere'  Hi, My... named 'aes-everywhere' How to remove the ModuleNotFoundError: No module named 'aes-everywhere' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'aes-keywrap'
ModuleNotFoundError: No module named 'aes-keywrap'  Hi, My Python... 'aes-keywrap' How to remove the ModuleNotFoundError: No module named 'aes-keywrap' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'aes-pipe'
ModuleNotFoundError: No module named 'aes-pipe'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'aes-pipe' How to remove the ModuleNotFoundError: No module named 'aes-pipe
ModuleNotFoundError: No module named 'aes-vial'
ModuleNotFoundError: No module named 'aes-vial'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'aes-vial' How to remove the ModuleNotFoundError: No module named 'aes-vial
ModuleNotFoundError: No module named 'alo-aes'
ModuleNotFoundError: No module named 'alo-aes'  Hi, My Python...-aes' How to remove the ModuleNotFoundError: No module named 'alo-aes... to install padas library. You can install alo-aes python with following command
ModuleNotFoundError: No module named 'easy-aes'
ModuleNotFoundError: No module named 'easy-aes'  Hi, My Python... 'easy-aes' How to remove the ModuleNotFoundError: No module named 'easy-aes... to install padas library. You can install easy-aes python with following
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
primary key and unique key
primary key and unique key  Whats is mean by primary key and unique key
Define candidate key, alternate key, composite key.
Define candidate key, alternate key, composite key.  Define candidate key, alternate key, composite key
Version of com.codahale>aes-gcm-siv dependency
List of Version of com.codahale>aes-gcm-siv dependency
forget password
forget password  codding for forget password using spring framework
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

Ads