Go to Top

Friday, 29 July 2011

Utilities - 1 : How to send encrypted messages to your closest friends ?

Hi folks! Today I am going to give such a program that will enable you to send encrypted messages to your best friends and it will also help you to decrypt those and get the messages from your friends.

Just paste the java program given below into your Blue-J or any other environment and follow the steps :


import java.lang.*;
import java.io.*;
class encrypt_1
{
 static void main()throws IOException
 {
     BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
     int a,opt=9;
     while(opt!=0)
     {
        System.out.println("Press 1 for encryption");
        System.out.println("Press 2 for decryption");
        System.out.print("\nEnter your choice : ");
        a=Integer.parseInt(br.readLine());
        System.out.print("\n");
        switch(a)
        {
            case 1:
            encrypt();
            break;
            case 2:
            decrypt();
            break;
            default:
            System.out.println("Invalid option");
        }
        System.out.println("\nPress 1 to restart");
        System.out.println("Press 0 to terminate the program");
        System.out.print("\nEnter your choice : ");
        opt=Integer.parseInt(br.readLine());
        System.out.print("\n");
    }
    System.out.println("Thank you for using this short program");
}
    static void encrypt()throws IOException
    {
        BufferedReader br1=new BufferedReader(new InputStreamReader(System.in));
        String a;
        char k;
        int i;
        System.out.print("Enter the string (Encryption process) : ");
        a=br1.readLine();
        System.out.print("\nYour encrypted data is : ");
        for(i=0;i<=a.length()-1;i++)
        {
            k=a.charAt(i);
            System.out.print((char)(k^129));
        }
        System.out.println("\n");
        System.out.println("Thank you for using this short program");
    }
     static void decrypt()throws IOException
    {
        BufferedReader br2=new BufferedReader(new InputStreamReader(System.in));
        String a;
        char k;
        int i;
        System.out.print("Enter the encrypted data : ");
        a=br2.readLine();
        System.out.print("\nYour decrypted data is : ");
        for(i=0;i<=a.length()-1;i++)
        {
            k=a.charAt(i);
            System.out.print((char)((int)k^129));
        }
        System.out.print("\n");
}
}


Give the program to your friends whom you want to recieve your messages only , and keep one copy for yourself too !

Compile the above program and run it. Follow the directions and turn your message, for example : "Let's meet at 5:30 in the park" into "Íäõ¦ò¡ìääõ¡àõ¡´»²±¡èï¡õéä¡ñàóê" . Copy it from the display and send it to your friend. When he/she decrypts it (by copying the code and pasting it into the program) , he/she will get the message "Let's meet at 5:30 in the park" and believe me, this will surely work and protect your message from being understood by your rivals. And please please comment on my articles to prove that you are out there somewhere reading my article. By the way, this encryption is called "Simple XOR Encryption" , and its quite simple and effective too !

No comments:

Post a Comment

ShareThis