UNPKG

cerceis-lib

Version:

Contains list of quality of life functions that is written in TypeScript and es6

75 lines (73 loc) 2.39 kB
type ObfuscatorVersion = "v1" | "v2" | "v3" | "v4"; interface ObfuscatorOptions { version?: ObfuscatorVersion; key?: string; } declare class Obfuscator { private readonly _v4Prefix; private readonly _base64UrlAlphabet; private readonly _randomKey; /** * Preferred obfuscation API. Defaults to V4. */ encode(inputStr: string, options?: ObfuscatorOptions): string; /** * Preferred deobfuscation API. V4 payloads are self-identifying. */ decode(inputStr: string, options?: ObfuscatorOptions): string; private _buildKeyValue; /** * V1 obfuscation - key-based character code encoding. * If no key is provided, a random key is generated and you cannot deobfuscate. * @param inputStr String to obfuscate. * @param key Optional key for reversibility. */ obfuscate(inputStr: string, key?: string): string; /** * V1 deobfuscation. * @param inputStr String to deobfuscate. * @param key Key used during obfuscation. */ deobfuscate(inputStr: string, key: string): string; private _swapPairs; /** * V2 obfuscation - pair-swapping with incremental key shifting. */ obfuscatev2(inputStr: string): string; /** * V2 deobfuscation. */ deobfuscatev2(inputStr: string): string; /** * V3 obfuscation - binary rotation with hex encoding. * @param inputStr String to obfuscate. * @param key Key used to determine rotation amounts. */ obfuscatev3(inputStr: string, key: string): string; /** * V3 deobfuscation. */ deobfuscatev3(inputStr: string, key: string): string; /** * V4 obfuscation - salted keyed byte-stream masking with base64url output. * This is reversible obfuscation, not cryptographic encryption. */ obfuscatev4(inputStr: string, key: string): string; /** * V4 deobfuscation. */ deobfuscatev4(inputStr: string, key: string): string; private _applyV4; private _seedFromKey; private _xorshift32; private _rotateLeftByte; private _rotateRightByte; private _randomSalt; private _base64UrlEncode; private _base64UrlDecode; private _base64UrlValue; private _requireKey; private _keyToValues; } declare const obfuscator: Obfuscator; export { Obfuscator, type ObfuscatorOptions, type ObfuscatorVersion, obfuscator };