-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencryptbypin.java
More file actions
62 lines (53 loc) · 1.63 KB
/
encryptbypin.java
File metadata and controls
62 lines (53 loc) · 1.63 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* Ankit Raj Biswal
1941012238
@_head_hunter25*/
package project;
import java.util.*;
public class encryptbypin {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
System.out.println("Enter 4 PIN Of Your Choice");
int n1=sc.nextInt(), n2=sc.nextInt(), n3=sc.nextInt(), n4=sc.nextInt();
char g=' ';
String gg="";
int c=0,cc=n1,d=0,e=0,f=0,n=0,nnn=0,m=0;
while (cc!=0){
cc=cc/10;
n+=1;
}
while(c<=n-1){
nnn=Math.min((n1%10),Math.min((n2%10),Math.min((n3%10),(n4%10))));
m=m+((int)Math.pow(10,c))*nnn;
n1=n1/10;
n2=n2/10;
n3=n3/10;
n4=n4/10;
c+=1;
}
System.out.println("The Generated Pin is :"+m);
System.out.println("Enter the message you want to encrypt");
String msg=sc.nextLine();
String nn=sc.nextLine();
nn=nn.replaceAll(" ","");
nn=nn.toLowerCase();
// System.out.println(n);
int k=nn.length();
c=0;
while(e<=k-1){
g=(nn.charAt(e));
d=m/((int)Math.pow(10,(n-1-c)));
d=d%10;
f=(int)g+d;
if(f>122){
f=96+(f-122);
}
gg=gg+((char)f);
c+=1;
if(c==n){
c=0;
}
e+=1;
}
System.out.print(gg.toUpperCase());
}
}