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



Home Answers Viewqa Java-Beginners Java Encryption using AES with key password
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Nishanth Thomas
Java Encryption using AES with key password
2 Answer(s)      2 years and 7 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);

      }

 }

Advertisement
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);

   }

}



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... 
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
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
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
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
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
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 create primary key using hibernate?
How to create primary key using hibernate?  Hi, How to create primary key using hibernate? Thanks
encryption and decryption
encryption and decryption  how to encrypt and decrypt data in text file
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
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
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
Softabar Password Manager
, is encrypted using AES encryption algorithm. Store accounts to server using Softabar Password Manager Server Storage... Softabar Password Manager   
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
sound encryption
sound encryption  i want to ask if there is a simple code to perform encryption on sound file
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 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 In Swing - Swing AWT
Encryption In Swing  Hi sir i have a JFrame Containing User Name and Password is there any way to encrypt password and how can we store the encrypted passwaord to MS ACCESS
encryption and decryption
encryption and decryption   ASCII encryptor I want to develop a program that encrypt and decrypt. The messages stored in a file should.... This is called encryption. When one wants to read the contents of the file
Advertisements
 

 

 

DMCA.com