redshoga / zero-width-watermark

Module for embedding information in text using zero-width characters.

Home Page:https://github.com/redshoga/zero-width-watermark

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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/

Example Web App Source: https://github.com/redshoga/zero-width-watermark-web

Usage

import { embed, extract } from "zero-width-watermark";

// embed
const embeddedText = embed("sample", "hello world🐾");
console.log({ embeddedText });
// {
//   embeddedText: "sβ€Œβ€‹β€‹β€Œβ€‹β€Œβ€Œβ€Œβ€Œβ€‹β€‹β€Œβ€Œβ€‹β€Œβ€‹β€Œβ€‹β€‹β€Œβ€‹β€‹β€Œβ€Œaβ€Œβ€‹β€‹β€Œβ€‹β€‹β€Œβ€Œβ€Œβ€‹β€‹β€Œβ€‹β€‹β€‹β€‹β€Œβ€Œβ€‹β€Œβ€Œβ€Œβ€Œβ€Œmβ€Œβ€‹β€‹β€‹β€Œβ€‹β€‹β€‹β€Œβ€‹β€‹β€Œβ€‹β€‹β€‹β€‹β€Œβ€‹β€‹β€‹β€Œβ€Œβ€‹β€Œpβ€Œβ€‹β€‹β€Œβ€‹β€‹β€Œβ€Œβ€Œβ€‹β€‹β€Œβ€Œβ€‹β€Œβ€Œβ€‹β€‹β€‹β€‹β€Œβ€Œβ€Œβ€Œlβ€‹β€Œβ€Œβ€‹β€‹β€‹β€‹β€‹β€‹β€Œβ€Œβ€‹β€Œβ€Œβ€Œβ€Œβ€‹β€Œβ€‹β€‹β€‹β€‹β€‹β€Œe";
// }

// 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(
  "Iβ€Œβ€‹β€‹β€Œβ€Œβ€‹β€‹β€‹β€Œβ€‹β€‹β€Œβ€Œβ€Œβ€Œβ€‹β€Œβ€Œβ€‹β€‹β€‹β€‹β€Œβ€Œpβ€Œβ€Œβ€‹β€Œβ€‹β€‹β€‹β€‹β€Œβ€‹β€Œβ€‹β€Œβ€‹β€‹β€‹β€Œβ€‹β€‹β€‹β€Œβ€Œβ€‹β€Œsβ€Œβ€‹β€‹β€Œβ€‹β€Œβ€Œβ€‹β€Œβ€‹β€‹β€‹β€Œβ€‹β€Œβ€Œβ€Œβ€‹β€‹β€‹β€Œβ€‹β€Œβ€Œuβ€Œβ€‹β€‹β€Œβ€Œβ€‹β€Œβ€‹β€Œβ€‹β€‹β€Œβ€‹β€‹β€‹β€Œβ€Œβ€‹β€Œβ€Œβ€Œβ€Œβ€‹β€Œmβ€Œβ€‹β€‹β€‹β€‹β€Œβ€Œβ€‹β€Œβ€Œβ€‹β€‹β€‹β€‹β€‹β€Œβ€Œβ€Œβ€‹β€‹β€‹β€‹β€Œβ€Œ β€Œβ€‹β€Œβ€‹β€Œβ€‹β€‹β€‹β€Œβ€‹β€‹β€‹β€Œβ€Œβ€‹β€Œβ€Œβ€‹β€‹β€Œβ€‹β€Œβ€Œβ€‹iβ€Œβ€‹β€‹β€‹β€Œβ€‹β€Œβ€Œβ€Œβ€‹β€‹β€‹β€Œβ€‹β€Œβ€Œβ€Œβ€‹β€‹β€Œβ€Œβ€‹β€Œβ€‹sβ€Œβ€‹β€‹β€Œβ€‹β€‹β€‹β€Œβ€Œβ€‹β€Œβ€Œβ€Œβ€Œβ€‹β€Œβ€Œβ€‹β€‹β€‹β€‹β€Œβ€Œβ€‹ β€Œβ€Œβ€‹β€‹β€‹β€‹β€‹β€Œβ€Œβ€‹β€Œβ€Œβ€Œβ€Œβ€Œβ€Œβ€Œβ€‹β€‹β€‹β€Œβ€Œβ€‹β€Œsβ€Œβ€‹β€‹β€Œβ€Œβ€‹β€Œβ€‹β€Œβ€‹β€‹β€Œβ€Œβ€‹β€Œβ€Œβ€Œβ€‹β€‹β€‹β€Œβ€Œβ€‹β€‹iβ€Œβ€‹β€‹β€Œβ€‹β€Œβ€Œβ€Œβ€Œβ€‹β€‹β€Œβ€‹β€‹β€‹β€‹β€Œβ€‹β€‹β€Œβ€Œβ€‹β€‹β€‹mβ€Œβ€‹β€‹β€Œβ€Œβ€Œβ€Œβ€‹β€Œβ€Œβ€‹β€‹β€‹β€‹β€Œβ€Œβ€Œβ€Œβ€‹β€Œβ€‹β€‹β€‹β€‹pβ€Œβ€‹β€Œβ€‹β€Œβ€‹β€‹β€‹β€Œβ€‹β€‹β€‹β€Œβ€Œβ€‹β€Œβ€Œβ€‹β€‹β€Œβ€‹β€Œβ€Œβ€‹lβ€Œβ€‹β€‹β€‹β€Œβ€‹β€Œβ€Œβ€Œβ€‹β€‹β€‹β€Œβ€‹β€Œβ€Œβ€Œβ€‹β€‹β€Œβ€Œβ€‹β€Œβ€‹yβ€Œβ€‹β€‹β€Œβ€‹β€‹β€‹β€Œβ€Œβ€‹β€Œβ€Œβ€Œβ€Œβ€‹β€Œβ€Œβ€‹β€‹β€‹β€‹β€Œβ€Œβ€‹ β€Œβ€Œβ€‹β€‹β€‹β€‹β€‹β€Œβ€Œβ€Œβ€‹β€‹β€‹β€‹β€Œβ€Œβ€Œβ€‹β€Œβ€‹β€Œβ€‹β€‹β€‹dβ€Œβ€‹β€‹β€‹β€Œβ€Œβ€‹β€Œβ€Œβ€‹β€‹β€Œβ€‹β€Œβ€Œβ€‹β€Œβ€‹β€‹β€‹β€Œβ€‹β€Œβ€Œuβ€Œβ€‹β€‹β€‹β€Œβ€‹β€Œβ€Œβ€Œβ€‹β€‹β€Œβ€Œβ€‹β€Œβ€‹β€Œβ€‹β€‹β€Œβ€‹β€‹β€‹β€Œmβ€Œβ€‹β€Œβ€Œβ€Œβ€Œβ€‹β€Œβ€Œβ€‹β€‹β€‹β€‹β€Œβ€Œβ€‹β€Œβ€Œβ€‹β€‹β€‹β€‹β€‹β€Œmβ€Œβ€‹β€Œβ€Œβ€Œβ€Œβ€Œβ€Œβ€Œβ€‹β€‹β€‹β€Œβ€Œβ€‹β€Œβ€Œβ€‹β€‹β€Œβ€Œβ€‹β€Œβ€‹yβ€Œβ€‹β€‹β€Œβ€Œβ€‹β€Œβ€Œβ€Œβ€‹β€‹β€‹β€Œβ€Œβ€‹β€‹β€Œβ€‹β€‹β€Œβ€‹β€Œβ€Œβ€Œ ",
  {
    outputType: "string",
  }
) as string;
// extraData: ga</WrittenBy><WrittenBy>@redshoga</WrittenBy><WrittenBy>@redshoga

const author = extraData.match(/<WrittenBy>(.+)<\/WrittenBy>/)[1];
// author: @redshoga

Licence

MIT

About

Module for embedding information in text using zero-width characters.

https://github.com/redshoga/zero-width-watermark


Languages

Language:TypeScript 97.7%Language:JavaScript 2.3%