0.0.6 β€’ Published 7 months ago

hide-data-in-string v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Hide Data In String⁠ ts ts ts

πŸ•΅ ️ About

hide-data-in-string is a lightweight npm package that enables you to embed and extract portable, hidden data within strings using invisible character encoding. These strings are fully portable and can be sent to and extracted by other applications using this library. By leveraging these special Unicode characters, this package ensures that data remains hidden in plain sight, making it ideal for applications that require discreet data storage or messaging within text. This package works with both CommonJS (CJS) and ECMAScript Modules (ESM), and includes full TypeScript support.

This is a simple example of data stenography, the practice of concealing data within non-obtrusive media, such as text or images, without altering its appearance to the human eye. With hide-data-in-string, you can apply this concept to web applications. This method ensures that your data remains hidden in plain sight, offering a stealthy solution for embedding metadata, secure messages, or tracking information in user-facing content.

Staring this repo π•šπ•€ π•₯𝕙𝕖 π•–π•’π•€π•šπ•–π•€π•₯ 𝕨𝕒π•ͺ π•₯𝕠 π•π• π• π•œ π•π•šπ•œπ•– 𝕒 π•₯π•–π•’π•ž 𝕑𝕝𝕒π•ͺ𝕖𝕣 π•¨π•šπ•₯𝕙𝕠𝕦π•₯ 𝕒𝕔π•₯𝕦𝕒𝕝𝕝π•ͺ π•”π• π•Ÿπ•₯π•£π•šπ•“π•¦π•₯π•šπ•Ÿπ•˜ π•’π•Ÿπ•ͺπ•₯π•™π•šπ•Ÿπ•˜ ✨🧠✨

πŸ’» Installation

npm

npm install hide-data-in-string

Or, if you're using Yarn

yarn add hide-data-in-string

🚒 Usage

importing

import { embedData, extractData, hasEmbeddedData } from 'hide-data-in-string';

Embedding hidden data into a string

const text = "Hello, World!";
const hiddenMessage = "The secret is monkey";
const stringWithEmbeddedData = embedData(text, hiddenMessage
console.log(stringWithEmbeddedData);
// "Hello, World!"

Extracting hidden data from a string

const extractedMessage = extractData(stringWithEmbeddedData);
console.log(extractedMessage);
// "The secret is monkey"

Checking for hidden data

console.log(hasEmbeddedData(stringWithEmbeddedData));  // true
const normalString = "Hello, World!"
console.log(hasEmbeddedData(normalString));  // false

πŸ‘½ Advanced Usage

Embedding and Extracting Complex Data (e.g., Objects) You can also hide more complex data, such as JSON objects, within strings. This is especially useful when you need to transmit or store data in a compact, discreet form without exposing it directly.

Embedding an object into a string

First, you'll need to serialize the object into a JSON string and then embed it into your target string. Here's how you can do that:

const user = {
  name: "John Doe",
  email: "john.doe@example.com",
  role: "admin"
};

const text = "Important message here";
const hiddenData = JSON.stringify(user);  

const stringWithEmbeddedData = embedData(text, hiddenData);
console.log(stringWithEmbeddedData);
// "Important message here"

const extractedData = extractData(stringWithEmbeddedData);
const parsedObject = JSON.parse(extractedData);
console.log(parsedObject);
// { name: "John Doe", email: "john.doe@example.com", role: "admin" }

πŸš€ Use Cases

  • Messaging with metadata: Embed information within text without altering its visible content.
  • Data Integrity: Track changes or store metadata in strings without risking exposure.
  • Privacy-Focused Applications: Hide tracking or session data in plain sight for non-invasive user identification.
  • Digital Watermarking: Embed invisible markers in content for copyright or attribution purposes.
  • Tracking Interactions: Store interaction data in text to monitor user behavior without cookies.
  • Anti-Fraud Measures: Conceal identifiers or hashes in strings for secure verification processes.

Please use hide-data-in-string resposibly. Let's keep things fair and respect privacy