diff --git a/package/app.ts b/package/app.ts index e87a18d..64ded37 100644 --- a/package/app.ts +++ b/package/app.ts @@ -14,26 +14,21 @@ const encrypta = (st: string, salt: string, d = 1) => { }; export const encrypt = ( - param: Object | string | number | any[], - salt: string, - d = 1 + param: Object | string | number | any[], + salt: string, + d = 1 ) => { - const hashSalt: number = hashFun(salt.trim().substring(0, 20)); - return JSON.stringify(param) - .split('') - .map((c, i) => - String.fromCharCode(c.charCodeAt(0) + configNum(hashSalt, i) * d) - ) - .join('') - .replace(/\\/g, 'blacard') - .replace(/\//g, 'danger') - .replace(/"/g, 'killer') - .replace(/'/g, 'terror') - .replace(/ /g, 'blankart') - .replace(/{/g, 'alpha') - .replace(/}/g, 'mega') - .replace(/`/g, 'omega'); + return encrypta(JSON.stringify(param), salt, d) + .replace(/\\/g, 'blacard') + .replace(/\//g, 'danger') + .replace(/"/g, 'killer') + .replace(/'/g, 'terror') + .replace(/ /g, 'blankart') + .replace(/{/g, 'alpha') + .replace(/}/g, 'mega') + .replace(/`/g, 'omega'); }; + export const decrypt = (str: string, salt: string) => { let encryption = encrypta( str diff --git a/package/hashFun.test.ts b/package/hashFun.test.ts index f7494fd..22e674e 100644 --- a/package/hashFun.test.ts +++ b/package/hashFun.test.ts @@ -7,7 +7,7 @@ describe("hashFun", () => { it("should return 1100101", () => { expect(hashFun("a")).toBe(1100101); }); - it("should return 1100101", () => { + it("should return 1100011010100000", () => { expect(hashFun("Secret*@+-1234")).toBe(1100011010100000); }); }); diff --git a/package/hashFun.ts b/package/hashFun.ts index 53e3143..50813e0 100644 --- a/package/hashFun.ts +++ b/package/hashFun.ts @@ -227,70 +227,6 @@ export const hashFun = (secret: string) => { case ',': hash = hash + 75; break; - case '-': - hash = hash + 0; - break; - case '.': - hash = hash + 0; - break; - case '/': - hash = hash + 0; - break; - case ':': - hash = hash + 0; - break; - case ';': - hash = hash + 0; - break; - case '<': - hash = hash + 0; - break; - case '=': - hash = hash + 0; - break; - case '>': - hash = hash + 0; - break; - case '?': - hash = hash + 0; - break; - case '@': - hash = hash + 0; - break; - case '[': - hash = hash + 0; - break; - case '\\': - hash = hash + 0; - break; - case ']': - hash = hash + 0; - break; - case '^': - hash = hash + 0; - break; - case '_': - hash = hash + 0; - break; - case '`': - hash = hash + 0; - break; - case '{': - hash = hash + 0; - break; - case '|': - hash = hash + 0; - break; - case '}': - hash = hash + 0; - break; - case '~': - hash = hash + 0; - break; - - default: - hash = hash + 0; - break; } charGen.push(hash); return hash & hash;