Skip to content

alreadyExisted/email-obfuscator

Repository files navigation

EmailObfuscator

Lib for obfuscate email on server and unobfuscate on client.

Installation

npm i -S @already-existed/email-obfuscator

Usage

<!-- html -->
<a data-email="true" href="mailto:[email-href]some-email@some.com[/email-href]">
  [email]some-email@some.com[/email]
</a>
// server
import { obfuscateEmail } from '@already-existed/email-obfuscator'

...
res.send(obfuscateEmail(html))
...
// client
import { unobfuscateEmail } from '@already-existed/email-obfuscator'

window.addEventListener('load', () => {
  unobfuscateEmail()
})

Options

// 'binary' - slow
// 'base64' - fast
type ObfuscateType = 'binary' | 'base64'

interface ObfuscateOptions {
  type?: ObfuscateType // default: 'binary'
}

obfuscateEmail(value: string, opts?: ObfuscateOptions): string
unobfuscateEmail(opts?: ObfuscateOptions): void

About

Lib for obfuscate email on server and unobfuscate on client.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published