tea-enc

1.0.1 • Public • Published

TeaEncryptor

A TeaEncryptor for encrypting and decrypting text into numbers using a custom character set and offset key.

Installation

You can install TeaEncryptor via npm:

npm install tea-enc

Usage

import TeaEncryptor from 'tea-enc';

// Create a new TeaEncryptor instance
const encryptor = new TeaEncryptor();

// Encrypt text
const encryptedText = encryptor.enc('Hello World');

// Decrypt text
const decryptedText = encryptor.dec(encryptedText);

console.log('Encrypted:', encryptedText);
console.log('Decrypted:', decryptedText);

Running Tests

You can run tests using npm:

npm run test

This will run the test script located at tests/test.js, which will encrypt and decrypt a sample text and output the results.

Expected output:

> tea-enc@1.0.0 test
> node tests/test.js

Encrypted Text: 168122113111113118105116182173109128124182132134134138
Decrypted Text: Original Text 1337

API

new TeaEncryptor([defaultBaseKey], [offsetKey])

Creates a new TeaEncryptor instance.

  • defaultBaseKey (optional): The default base key for encryption.
  • offsetKey (optional): The offset key used for generating the final base key.

TeaEncryptor.set(defaultBaseKey, [offsetKey])

Sets the base key and flipped base key for encryption and decryption.

  • defaultBaseKey: The default base key for encryption.
  • offsetKey (optional): The offset key used for generating the final base key.

TeaEncryptor.enc(textInput)

Encrypts the input text using the base key.

  • textInput: The text to be encrypted. Returns the encrypted text.

TeaEncryptor.dec(textInput)

Decrypts the input text using the base key.

  • textInput: The text to be decrypted. Returns the decrypted text.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Package Sidebar

Install

npm i tea-enc

Weekly Downloads

144

Version

1.0.1

License

MIT

Unpacked Size

9.1 kB

Total Files

6

Last publish

Collaborators

  • dxrry