-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
71 lines (67 loc) · 1.68 KB
/
main.js
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
63
64
65
66
67
68
69
70
71
let selOpt;
btnChipher.onclick=function(){
let p=passval.value;
let selOpt=sel.value;
res.value=chipher(p,parseInt(selOpt));
}
btnDecription.onclick=function(){
let p=passval.value;
let selOpt=sel.value;
res.value=decription(p,parseInt(selOpt));
}
btnDelete.onclick=function(){
passval.value='';
res.value="";
}
let arr=[];
for(let i=97; i<=122; i++){
arr.push(String.fromCharCode(i));
}
function chipher(password, n){
let chipherPass='';
for(let i=0; i<password.length; i++){
let currentIndex=arr.indexOf(password[i]);
if (currentIndex+n<=arr.length-1){
currentIndex+=n;
chipherPass+=arr[currentIndex];
}else{
let rem=arr.length-currentIndex;
currentIndex=n-rem;
chipherPass+=arr[currentIndex];
}
}
return(chipherPass);
}
chipher('creator',3);
function decription(password, n){
let decriptionPass='';
for(let i=0; i<password.length;i++){
let currentIndex=arr.indexOf(password[i]);
if(currentIndex-n>=0){
currentIndex-=n;
decriptionPass+=arr[currentIndex];
}else{
let rem=n-currentIndex;
currentIndex=arr.length-rem;
decriptionPass+=arr[currentIndex];
}
}
return(decriptionPass);
}
decription('fuhdwru',3)
darkMode.onclick=()=>{
function DL(){
let dMode=localStorage.getItem('darkmode')==='true';
localStorage.setItem('darkmode', JSON.stringify(dMode));
if(dMode==='true'){
localStorage.setItem('DarkModeNow', 'false');
}else{
localStorage.setItem('DarkModeNow', 'true');
wrapp.style.backgroundColor="#333";
title.style.color="#fff";
card.style.backgroundColor="#efefef";
card.style.border="none";
}
}
DL();
}