UD-Cipher Documentation

About UD-Cipher

UD-Cipher is a lightweight PHP and JavaScript library for encoding and decoding text using customizable symbol mappings and noise symbols. This mini encoding library provides an easy way to obfuscate text, making it suitable for various applications where text privacy is a concern.

Features

Installation

Prerequisites

PHP 7.4+

Step-by-step Guide

  1. Clone the Repository
    git clone https://github.com/codetesla51/ud-cipher.git
    cd ud-cipher
                        
  2. Open Your Editor/IDE
  3. Include the UD-Cipher Library
    require "src/init.php";
    use UDC\SymbolMapper;
    use UDC\NoiseGenerator;
    use UDC\UDC;
  4. Define Your Mappings and Noise Symbols
     $mappings = [
         "A" => ["𑁄𑀲𓋆𑁼", "𑀦𑌶𑁛𐬌", "𑁋𓁋𑀐𓅐", "𓂇𓅕𐬛𐬰"],
      "B" => ["𑁭𑌦𓈉𑁜", "𐬓𑁒𓍯𓀍", "𓈉𐬯𑁠𑅕", "𑁷𓋣𑌨𓌪"],
      "C" => ["𓏭𓄿𐬀𑌳", "𐬢𑁦𓇽𓂷", "𑀘𐬢𑁈𑁠", "𓍗𑁖𓈏𐬮"],
    ]
    
    $noiseSymbols = [  "⩓","⚿", "☢","⛧","♯","⩠"];
  5. Instantiate the Classes
    $symbolMapper = new SymbolMapper($mappings);
    $noiseGenerator = new NoiseGenerator($noiseSymbols);
    $encryptor = new UDC($symbolMapper, $noiseGenerator);

Usage

For encoding and decoding text, use the following PHP code:

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $text = $_POST["text"];
    $encryptedText = $encryptor->encryptText($text);
    echo "Encrypted Text: " . $encryptedText;
    $decryptedText = $encryptor->decryptText($encryptedText);
    echo "Decrypted Text: " . $decryptedText;
}

JavaScript Version

The JavaScript version offers similar functionalities. It can be implemented as follows:

const symbolMapper = new SymbolMapper(mappings);
const noiseGenerator = new NoiseGenerator(noiseSymbols);
const encryptor = new UDC(symbolMapper, noiseGenerator);

const encryptedText = encryptor.encryptText("Hello World");
console.log("Encrypted Text:", encryptedText);
const decryptedText = encryptor.decryptText(encryptedText);
console.log("Decrypted Text:", decryptedText);

Examples

PHP Examples

Here are some examples of using UD-Cipher in PHP:

Example 1: Basic Encoding and Decoding

$text = "Hello World";
$encryptedText = $encryptor->encryptText($text);
echo "Original Text: $text\n";
echo "Encrypted Text: $encryptedText\n";
$decryptedText = $encryptor->decryptText($encryptedText);
echo "Decrypted Text: $decryptedText\n;

Expected Output:

Original Text: Hello World
Encrypted Text: 𐭁𑉅𐬠𓏉 𓂋𑅕𑀜𐬋 𐬞𐬰𑀅𓋎 ☨ 𑀤𑌼𑍑𓅜 𐬴𓈃𑌭𓇈 𓁄𓀲𓋆𑁼 ⚰ 𐌀𐌈𐬅𑁮 𑄧𑀌𓌵𑁈 ✬ 𓌔𑌞𐌌𓍏 ♖ 𑀼𐬊𑌆𓉎 ⨟ 𐬴𐬙𓍋𓈚
Decrypted Text: Hello World

JavaScript Examples

Here are some examples of using UD-Cipher in JavaScript:

Example 1: Basic Encoding and Decoding

const text = "Hello World";
const encryptedText = encryptor.encryptText(text);
console.log("Original Text:", text);
console.log("Encrypted Text:", encryptedText);
const decryptedText = encryptor.decryptText(encryptedText);
console.log("Decrypted Text:", decryptedText);

Expected Output:

Original Text: Hello World
Encrypted Text: 𐭁𑉅𐬠𓏉 𓂋𑅕𑀜𐬋 𐬞𐬰𑀅𓋎 ☨ 𑀤𑌼𑍑𓅜 𐬴𓈃𑌭𓇈 𓁄𓀲𓋆𑁼 ⚰ 𐌀𐌈𐬅𑁮 𑄧𑀌𓌵𑁈 ✬ 𓌔𑌞𐌌𓍏 ♖ 𑀼𐬊𑌆𓉎 ⨟ 𐬴𐬙𓍋𓈚
Decrypted Text: Hello World