topkat-utils 1.2.93 → 1.2.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -15,7 +15,8 @@ const getCharIndex = (char) => {
|
|
|
15
15
|
};
|
|
16
16
|
/** simple and quick encoding, this is meant to obfuscate JWT encoding so we can
|
|
17
17
|
not decode it with something like https://jwt.io/
|
|
18
|
-
|
|
18
|
+
* * ⚠️🚸 special characters are actually not supported
|
|
19
|
+
* * string will be obfuscated so the characters are not in order
|
|
19
20
|
*/
|
|
20
21
|
function simpleEncryption(strR, secret, decode = false) {
|
|
21
22
|
const secretNb = secret.split('').map(char => char.charCodeAt(0) % 16 || -1);
|
|
@@ -29,11 +30,29 @@ function simpleEncryption(strR, secret, decode = false) {
|
|
|
29
30
|
return decode ? parsed.replace(/\$/g, '.') : parsed;
|
|
30
31
|
}
|
|
31
32
|
function simpleEncryptionEncode(str, secret) {
|
|
32
|
-
|
|
33
|
+
const strFromStart = [];
|
|
34
|
+
const strFromEnd = [];
|
|
35
|
+
str.split('').forEach((char, i) => {
|
|
36
|
+
if (i % 2)
|
|
37
|
+
strFromStart.push(char);
|
|
38
|
+
else
|
|
39
|
+
strFromEnd.push(char);
|
|
40
|
+
});
|
|
41
|
+
return simpleEncryption(strFromStart.join('') + strFromEnd.reverse().join(''), secret, false);
|
|
33
42
|
}
|
|
34
43
|
exports.simpleEncryptionEncode = simpleEncryptionEncode;
|
|
35
44
|
function simpleEncryptionDecode(str, secret) {
|
|
36
|
-
|
|
45
|
+
const decoded = simpleEncryption(str, secret, true);
|
|
46
|
+
const newStr = [];
|
|
47
|
+
const decodedArr = decoded.split('');
|
|
48
|
+
let i = 0;
|
|
49
|
+
while (decodedArr.length) {
|
|
50
|
+
if (i++ % 2)
|
|
51
|
+
newStr.push(decodedArr.shift());
|
|
52
|
+
else
|
|
53
|
+
newStr.push(decodedArr.pop());
|
|
54
|
+
}
|
|
55
|
+
return newStr.join('');
|
|
37
56
|
}
|
|
38
57
|
exports.simpleEncryptionDecode = simpleEncryptionDecode;
|
|
39
58
|
//# sourceMappingURL=encryptionUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryptionUtils.js","sourceRoot":"","sources":["../../src/encryptionUtils.ts"],"names":[],"mappings":";;;AAGA,MAAM,aAAa,GAAG,mEAAmE,CAAA;AACzF,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,EAAE;IAC5B,IAAI,CAAC,IAAI,aAAa,CAAC,MAAM;QAAE,OAAO,aAAa,CAAC,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,CAAA;IAC7E,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,aAAa,CAAC,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,CAAA;;QACpD,OAAO,aAAa,CAAC,CAAC,CAAC,CAAA;AAChC,CAAC,CAAA;AACD,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,EAAE;IAClC,OAAO,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;AACtC,CAAC,CAAA;AAGD
|
|
1
|
+
{"version":3,"file":"encryptionUtils.js","sourceRoot":"","sources":["../../src/encryptionUtils.ts"],"names":[],"mappings":";;;AAGA,MAAM,aAAa,GAAG,mEAAmE,CAAA;AACzF,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,EAAE;IAC5B,IAAI,CAAC,IAAI,aAAa,CAAC,MAAM;QAAE,OAAO,aAAa,CAAC,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,CAAA;IAC7E,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,aAAa,CAAC,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,CAAA;;QACpD,OAAO,aAAa,CAAC,CAAC,CAAC,CAAA;AAChC,CAAC,CAAA;AACD,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,EAAE;IAClC,OAAO,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;AACtC,CAA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,EAAE,CAAC,EAAE,EAAE;QAC9B,IAAI,CAAC,GAAG,CAAC;YAAE,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;;YAC7B,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC9B,CAAC,CAAC,CAAA;IACF,OAAO,gBAAgB,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;AACjG,CAAC;AARD,wDAQC;AAED,SAAgB,sBAAsB,CAAC,GAAW,EAAE,MAAc;IAC9D,MAAM,OAAO,GAAG,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;IACnD,MAAM,MAAM,GAAG,EAAc,CAAA;IAC7B,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IACpC,IAAI,CAAC,GAAG,CAAC,CAAA;IACT,OAAO,UAAU,CAAC,MAAM,EAAE;QACtB,IAAI,CAAC,EAAE,GAAG,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAY,CAAC,CAAA;;YACjD,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,EAAY,CAAC,CAAA;KAC/C;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAC1B,CAAC;AAVD,wDAUC"}
|
package/package.json
CHANGED
package/src/encryptionUtils.ts
CHANGED
|
@@ -14,7 +14,8 @@ const getCharIndex = (char: string) => {
|
|
|
14
14
|
|
|
15
15
|
/** simple and quick encoding, this is meant to obfuscate JWT encoding so we can
|
|
16
16
|
not decode it with something like https://jwt.io/
|
|
17
|
-
|
|
17
|
+
* * ⚠️🚸 special characters are actually not supported
|
|
18
|
+
* * string will be obfuscated so the characters are not in order
|
|
18
19
|
*/
|
|
19
20
|
function simpleEncryption(strR: string, secret: string, decode = false): string {
|
|
20
21
|
|
|
@@ -32,9 +33,23 @@ function simpleEncryption(strR: string, secret: string, decode = false): string
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
export function simpleEncryptionEncode(str: string, secret: string) {
|
|
35
|
-
|
|
36
|
+
const strFromStart = [] as string[]
|
|
37
|
+
const strFromEnd = [] as string[]
|
|
38
|
+
str.split('').forEach((char, i) => {
|
|
39
|
+
if (i % 2) strFromStart.push(char)
|
|
40
|
+
else strFromEnd.push(char)
|
|
41
|
+
})
|
|
42
|
+
return simpleEncryption(strFromStart.join('') + strFromEnd.reverse().join(''), secret, false)
|
|
36
43
|
}
|
|
37
44
|
|
|
38
45
|
export function simpleEncryptionDecode(str: string, secret: string) {
|
|
39
|
-
|
|
46
|
+
const decoded = simpleEncryption(str, secret, true)
|
|
47
|
+
const newStr = [] as string[]
|
|
48
|
+
const decodedArr = decoded.split('')
|
|
49
|
+
let i = 0
|
|
50
|
+
while (decodedArr.length) {
|
|
51
|
+
if (i++ % 2) newStr.push(decodedArr.shift() as string)
|
|
52
|
+
else newStr.push(decodedArr.pop() as string)
|
|
53
|
+
}
|
|
54
|
+
return newStr.join('')
|
|
40
55
|
}
|