Java Encryption using AES with key password

Ads

 
 

Share on Google+Share on Google+

Nishanth Thomas
Java Encryption using AES with key password
2 Answer(s)      5 years and 5 months ago
Posted in : Java Beginners
    /* AES alogrithm using password key */
   /* 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.BASE64Encoder;

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

  public class testencrypt {


  Cipher cipher; 
  // Input encrypted String
  static  String input = "Hi This is my String";
  // password for encryption
  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{

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

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

    // encrypt data 
     byte[] ecrypted = cipher.doFinal(input.getBytes());

     // encode data using standard encoder
     String output =  new BASE64Encoder().encode(ecrypted);

     System.out.println("Orginal tring: " + input);
     System.out.println("Encripted string: " + output);

      }

 }
Ads
View Answers

May 22, 2012 at 11:31 AM


  /* AES encryption alogrithm in JAVA */  
  /* AES alogrithm using password key */
  /* 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.BASE64Encoder;

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

  public class testencrypt {


 Cipher cipher; 
 // Input encrypted String
 static  String input = "Hi This is my String";
 // password for encryption
  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{

  // Parameter specific algorithm
 AlgorithmParameterSpec paramSpec = new IvParameterSpec(strPassword.getBytes()); 

  //Whatever you want to encrypt/decrypt
  Cipher cipher =  Cipher.getInstance("AES/CBC/PKCS5Padding");

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

  // encrypt data 
   byte[] ecrypted = cipher.doFinal(input.getBytes());

   // encode data using standard encoder
   String output =  new BASE64Encoder().encode(ecrypted);

   System.out.println("Orginal tring: " + input);
   System.out.println("Encripted string: " + output);

   }

}



May 22, 2012 at 11:31 AM


  /* AES encryption alogrithm in JAVA */  
  /* AES alogrithm using password key */
  /* 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.BASE64Encoder;

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

  public class testencrypt {


 Cipher cipher; 
 // Input encrypted String
 static  String input = "Hi This is my String";
 // password for encryption
  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{

  // Parameter specific algorithm
 AlgorithmParameterSpec paramSpec = new IvParameterSpec(strPassword.getBytes()); 

  //Whatever you want to encrypt/decrypt
  Cipher cipher =  Cipher.getInstance("AES/CBC/PKCS5Padding");

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

  // encrypt data 
   byte[] ecrypted = cipher.doFinal(input.getBytes());

   // encode data using standard encoder
   String output =  new BASE64Encoder().encode(ecrypted);

   System.out.println("Orginal tring: " + input);
   System.out.println("Encripted string: " + output);

   }

}


Ads









Related Tutorials/Questions & Answers:
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
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
Advertisements
AES encryption in J2ME
AES encryption in J2ME  Is it possible to do aes encryption in j2me
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 in php - PHP
password encryption in php  example of password encryption in php
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... 
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
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
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.
Encryption Decryption In Scriptlets/Java
Encryption Decryption In Scriptlets/Java  I have this code in my scriptlet, when I use the Encryption code to encrypt my data it executes... 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
array password - Java Beginners
array password  i had create a GUI of encryption program that used the array password. my question is can we do the password change program? i mean we change the older password with the new password
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
java password function
java password function  secret password function
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
Version of com.amazonaws>aws-dynamodb-encryption-java dependency
List of Version of com.amazonaws>aws-dynamodb-encryption-java dependency
Version of com.amazonaws>aws-encryption-sdk-java dependency
List of Version of com.amazonaws>aws-encryption-sdk-java dependency
java key value pair
java key value pair  Hi, How to save the java key value pair in Java? Thanks   Hi, You can use the Hashtable for this purpose. Check the tutorial Creating a Hash Table. Thanks
How to create primary key using hibernate?
How to create primary key using hibernate?  Hi, How to create primary key using hibernate? Thanks
Password - Java Beginners
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.... http://www.roseindia.net/java/example/java/swing/ Thanks
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... How to handle the text using Key Listener Interface... are going to show you how to display the text of textField1 on the text field2 on key
registration key - Java Beginners
registration key  I want the serial key for JCreator Pro 4.50. I lost it. If any body has it please send
How to supress displaying username and password in Java Web Start 10.21.2.11 Using JRE version 1.7.0_21-b11 Java HotSpot(TM) Client VM
How to supress displaying username and password in Java Web Start 10.21.2.11 Using JRE version 1.7.0_21-b11 Java HotSpot(TM) Client VM  I have installed Java 1.7.21 from java 1.6. I am observing username and password (match
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
login-password - Java Beginners
login-password  complete code of login-password form then how...; } if(theForm.password.value==""){ //please enter passward alert("Please enter Password...: Password
Maven Dependency aws-dynamodb-encryption-java >> 1.11.0
You should include the dependency code given in this page to add Maven Dependency of com.amazonaws >> aws-dynamodb-encryption-java version1.11.0 in your project
Maven Dependency aws-encryption-sdk-java >> 0.0.1
You should include the dependency code given in this page to add Maven Dependency of com.amazonaws >> aws-encryption-sdk-java version0.0.1 in your project
Softabar Password Manager
, is encrypted using AES encryption algorithm. Store accounts to server using Softabar Password Manager Server Storage... Softabar Password Manager   
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

Ads

 
Advertisement null

Ads