zero-width-watermark
v0.1.3
Published
Module for embedding information in text using zero-width characters
Downloads
16
Readme
zero-width-watermark
Module for embedding information in text using zero-width characters
NPM: https://www.npmjs.com/package/zero-width-watermark
Example Web App: https://zero-width-watermark-web.vercel.app/
Usage
import { embed, extract } from "zero-width-watermark";
// embed
const embeddedText = embed("sample", "hello world🐾");
console.log({ embeddedText });
// {
// embeddedText: "sample";
// }
// extractText
const extractText = extract(embeddedText);
console.log({ extractText });
// { extractText: 'hello world🐾' }
Example of use
Copyright protection
embed
const copyrightInfo = "<WrittenBy>@redshoga</WrittenBy>";
const blogText =
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s";
const embeddedBlogText = embed(blogText, copyrightInfo, { repeat: 10 });
extract
const extraData = extract(
"Ipsum is simply dummy ",
{
outputType: "string",
}
) as string;
// extraData: ga</WrittenBy><WrittenBy>@redshoga</WrittenBy><WrittenBy>@redshoga
const author = extraData.match(/<WrittenBy>(.+)<\/WrittenBy>/)[1];
// author: @redshoga
Licence
MIT