Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Encryption{
- static void intEncrypt(String string){
- String str = string;
- char[] ch = str.toCharArray();
- char ch1[] = new char[ch.length];
- //displaying the entered string
- System.out.println("\nEncrypted String is ::");
- for(int i=0;i<ch.length;i++)
- {
- System.out.print(ch[i]);
- }
- int c=ch.length-1;
- for(int i=0;i<ch.length;i++)
- {
- ch1[i]=(char)(ch[i]+c);
- c--;
- }
- //reverse print
- System.out.println("\nEncrypted String is ::");
- for( int i=0;i<=ch1.length-1;i++)
- System.out.print((ch1[i]));
- }
- public static void main(String args[]){
- String str="sample";
- intEncrypt(str);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment