-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchangesMade.js
More file actions
145 lines (117 loc) · 3.2 KB
/
Copy pathchangesMade.js
File metadata and controls
145 lines (117 loc) · 3.2 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
var {moreSalting} = require('./algos/somersault')
const hash = function (string, pass) {
const input = string;
var salt = parseInt(pass);
var extraSalt = moreSalting(salt);
if(salt>26){
salt = salt%26;
}
var inpArr = input.split('');
var output = []
for (i = 0; i < inpArr.length; i++) {
var conV = inpArr[i].charCodeAt(0);
var outSign = parseInt(conV) + parseInt(salt)
var saltSign = outSign - extraSalt;
let EncryptText = String.fromCharCode(saltSign);
output.push(EncryptText);
}
outputStr = output.join('')
const bConvert = Buffer.from(outputStr).toString('base64');
var outPut = moreEncryption(bConvert, salt, 'encrypt')
return outPut;
}
const revHash = function (string, pass) {
const inputRev = string;
var saltRev = parseInt(pass);
var extraSaltRev = moreSalting(saltRev);
if(saltRev>26){
saltRev = saltRev % 26;
}
const bReverse = Buffer.from(inputRev, 'base64').toString();
var revArr = bReverse.split('');
var revOutput = []
for (j = 0; j < revArr.length; j++) {
var revConV = revArr[j].charCodeAt(0);
var revOutSign = parseInt(revConV) - parseInt(saltRev);
var saltSign = revOutSign + extraSaltRev;
let decryptText = String.fromCharCode(saltSign);
revOutput.push(decryptText)
}
revOutputStr = revOutput.join('')
var outPutRev = moreEncryption(revOutputStr, saltRev,'decrypt') // -------- check if return direct is working or not
return outPutRev;
}
algoOne()
algoTwo()
algoThree()
algoFour()
algoFive()
function moreEncryption(moreInput, morePass, typeOfCrypt){
fDigit = morePass.toString()[0];
if(fDigit == 1 || fDigit == 4){
algoOne(moreInput, morePass, typeOfCrypt)
}
else if(fDigit==2 || fDigit == 7){
algoTwo(moreInput, morePass, typeOfCrypt)
}
else if(fDigit==3 || fDigit == 5){
algoThree(moreInput, morePass, typeOfCrypt)
}
else if(fDigit==6 || fDigit == 9){
algoFour(moreInput, morePass, typeOfCrypt)
}
else if(fDigit==8){
algoFive(moreInput, morePass, typeOfCrypt)
}
}
function algoOne(s, n, typeOfCrypt){
if(typeOfCrypt == 'encrypt'){
hash(s, parseInt(n-150))
}
else{
hash(s, parseInt(n+150))
}
return res;
}
function algoTwo(s, n, typeOfCrypt){
if(typeOfCrypt == 'encrypt'){
hash(s, parseInt(n-69))
}
else{
hash(s, parseInt(n+69))
}
return res;
}
function algoThree(s, n, typeOfCrypt){
if(typeOfCrypt == 'encrypt'){
hash(s, parseInt(n-92))
}
else{
hash(s, parseInt(n+92))
}
return res;
}
function algoFour(s, n, typeOfCrypt){
if(typeOfCrypt == 'encrypt'){
hash(s, parseInt(n-49))
}
else{
hash(s, parseInt(n+49))
}
return res;
}
function algoFive(s, n, typeOfCrypt){
if(typeOfCrypt == 'encrypt'){
hash(s, parseInt(n-91))
}
else{
hash(s, parseInt(n+91))
}
return res;
}
module.exports = {hash, revHash}
// const key = require('keyhasher');
// var op = key.hash('okay', 3);
// console.log(op)
// var op2 = key.revHash(op, 3);
// console.log(op2)