forked from shivamkaushik12007/Encryption-Decryption
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnicode.java
More file actions
26 lines (25 loc) · 684 Bytes
/
Copy pathUnicode.java
File metadata and controls
26 lines (25 loc) · 684 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package encryptdecrypt;
public class Unicode implements Algorithm{
public String encrypt(String str,int k){
int n=str.length();
String res=new String("");
for(int i=0;i<n;i++){
char ch=str.charAt(i);
int asc=(int)ch+k;
ch=(char)asc;
res+=Character.toString(ch);
}
return res;
}
public String decrypt(String str,int k){
int n=str.length();
String res=new String("");
for(int i=0;i<n;i++){
char ch=str.charAt(i);
int asc=(int)ch-k;
ch=(char)asc;
res+=Character.toString(ch);
}
return res;
}
}