rajamit872

Encyption of string asked in AMCAT

Sep 22nd, 2014
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. class Encryption{
  2. static void intEncrypt(String string){
  3. String str = string;
  4. char[] ch = str.toCharArray();
  5. char ch1[] = new char[ch.length];
  6. //displaying the entered string
  7. System.out.println("\nEncrypted String is ::");
  8. for(int i=0;i<ch.length;i++)
  9. {
  10. System.out.print(ch[i]);
  11. }
  12. int c=ch.length-1;
  13. for(int i=0;i<ch.length;i++)
  14. {
  15. ch1[i]=(char)(ch[i]+c);
  16. c--;
  17. }
  18. //reverse print
  19. System.out.println("\nEncrypted String is ::");
  20. for( int i=0;i<=ch1.length-1;i++)
  21. System.out.print((ch1[i]));
  22. }
  23. public static void main(String args[]){
  24. String str="sample";
  25. intEncrypt(str);
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment