Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

UPLOAD TEXTFILE USING CYPERTEXT USING JAVA

import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;

public class HelloWorld{
    public static void main(String[] args) {

        try{
            KeyGenerator keygenerator = KeyGenerator.getInstance("DES");
            SecretKey myDesKey = keygenerator.generateKey();

            Cipher desCipher;
            desCipher = Cipher.getInstance("DES");


            byte[] text = "No body can see me.".getBytes("UTF8");


            desCipher.init(Cipher.ENCRYPT_MODE, myDesKey);
            byte[] textEncrypted = desCipher.doFinal(text);

            String s = new String(textEncrypted);
            System.out.println(s);

            desCipher.init(Cipher.DECRYPT_MODE, myDesKey);
            byte[] textDecrypted = desCipher.doFinal(textEncrypted);

            s = new String(textDecrypted);
            System.out.println(s);
        }catch(Exception e)
        {
            System.out.println("Exception");
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: seek bar 
Java :: feign client url from properties 
Java :: double if statement java 
Java :: java null 
Java :: java create array with values 
Java :: java do while loop 
Java :: fix nullpointerexception 
Java :: java load jar at runtime 
Java :: java file search recursive 
Java :: java packages example 
Java :: java confirmation dialog 
Java :: how to find a word in a statement java 
Java :: index 1 out of bound for length 1 java 
Java :: java record 
Java :: observer design pattern 
Java :: parameterized constructor java 
Java :: how to find lcm of two numbers java 
Java :: creating an object in java 
Java :: Adding Entire ArrayList to another ArrayList in Java 
Java :: Passing data from an activity to a fragment 
Java :: java startswith regex 
Java :: add string to array java 
Java :: Java Exception handling using try...catch 
Java :: arraylist sort 
Java :: set array length java 
Java :: Java Access LinkedList elements 
Java :: BufferedReader x = new BufferedReader(new InputStreamReader(System.in)); 
Java :: factorial recursion java 
Java :: efficient java code to reverse array elements 
Java :: ex: java loop 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =