@dxrry/tea-encryptor

1.2.0 • Public • Published

tea-encryptor

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

Installation

You can install @dxrry/tea-encryptor via npm:

npm install @dxrry/tea-encryptor

Usage

import TeaEncryptor from '@dxrry/tea-encryptor';

// 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:

> @dxrry/tea-encryptor@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.

Btw

This repository is a OSS Project for tea.xyz.

License

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

Readme

Keywords

Package Sidebar

Install

npm i @dxrry/tea-encryptor

Weekly Downloads

1

Version

1.2.0

License

MIT

Unpacked Size

7.67 kB

Total Files

5

Last publish

Collaborators

  • dxrry