Skip to content

deobfuscate

Reverses obfuscate. Never throws: a token that obfuscate could not have produced (another alphabet, padding, broken length, bytes that are not UTF-8, not a string) gives null.

Available since v3.1.9

import { deobfuscate } from '@helpers4/string';
// or, from the all-in-one package (same code, one install):
import { deobfuscate } from 'helpers4/string';
deobfuscate(token: string): string | null
ParameterTypeDescription
tokenstringA token returned by obfuscate

string | null — The original text, or null for an invalid token

Reverses obfuscate, in Node.js and in browsers alike.

deobfuscate('bW9jLmVscG1heGVAZW0')
// => 'me@example.com'

It never throws, so the caller just checks for null.

deobfuscate('not a token!')
// => null

View source on GitHub