Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Encode {
- public static void main(String args[]) {
- String msg = " This is a test";
- String encmsg = " ";
- String decmsg = " ";
- int key = 77;
- System.out.print("Original Message: " );
- System.out.println(msg);
- for(int i = 0; i < msg.length(); i++) {
- encmsg = encmsg + (char) (msg.charAt(i) ^ key);
- }
- System.out.print("Encoded Message: ");
- System.out.println(encmsg);
- for(int i = 0; i < msg.length(); i++) {
- decmsg = decmsg + (char) (encmsg.charAt(i) ^ key);
- }
- System.out.print("Decoded Message: ");
- System.out.println(decmsg);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement