UNPKG

encryption-tool-ts-fox_hunt

Version:

Ascii encryption tool for strings

28 lines (22 loc) 690 B
export function encryptString(string: string, encId: number): string { let result: string = ""; // Encrypt for (let i = 0; i < string.length; i++) { const code = string.charCodeAt(i); const offset = code + encId; const offsetChar = String.fromCharCode(offset); result += offsetChar; } return result; } export function decryptString(string: string, decId: number): string { let result: string = ""; // Decrypt for (let i = 0; i < string.length; i++) { const code = string.charCodeAt(i); const offset = code - decId; const offsetChar = String.fromCharCode(offset); result += offsetChar; } return result; }