AES Decryption using key password

Ads

 
 
 

Share on Google+Share on Google+

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

   }

 }
Ads
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));    

 }

}


Ads









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
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 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... 
How to create primary key using hibernate?
How to create primary key using hibernate?  Hi, How to create primary key using hibernate? Thanks
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
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 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
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
Password
Password  make a program which ask ask the username and password * in this format. in C language
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
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
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
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
primary key and unique key
primary key and unique key  Whats is mean by primary key and unique key
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
Tutorials   
Java Spring Hibernate Struts Training java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient How do I resolve this Java Class not found exception? httpclient java.lang.NoClassDefFoundError Apache Commons ioutils maven dependency Read/Convert an inputStream to a String What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java Java Example Codes and Tutorials in 2017 How do I read a large file quickly in Java? Is learning Java worthwhile?

Ads

 
Advertisement null

Ads