tch1
v1.0.1
Published
A custom TCH1 language (created by TurboChat) hash creator. Disclaimer: This is not the most secure option. Please use other official langauges for the most secure option.
Downloads
137
Readme
TCH1.js Documentation
Welcome to the documentation for TCH1.js, a custom one-way hash encrypter built using the TCH1 language. This tool allows you to securely hash input strings without relying on external libraries, making it lightweight and easy to integrate into your projects.
Disclaimer
TCH1.js is an experimental tool intended for educational and non-critical applications. For more secure and robust hashing solutions, it is recommended to use official cryptographic libraries and established standards.
Table of Contents
How to Use
Install via npm
To use TCH1.js in your project, install it using npm:
```bash npm install tch1 ```
Import TCH1.js into Your Project
For CommonJS (Node.js)
```javascript const TCH1 = require('tch1');
const input = "hello world"; const hash = TCH1.hash(input); console.log("Hash:", hash); ```
For ES Modules
```javascript import TCH1 from 'tch1';
const input = "hello world"; const hash = TCH1.hash(input); console.log("Hash:", hash); ```
Using TCH1.js in Browser with Module Bundlers
```javascript import TCH1 from 'tch1';
const input = "hello world"; const hash = TCH1.hash(input); console.log("Hash:", hash); ```
Using TCH1.js Directly in Websites
Include TCH1.js by referencing the local `tch1.js` file:
```html
```
Function Breakdown
hash(input, salt, rounds): Generates a one-way hash of the input string.
Parameters:
- input: `string` - The input string you want to hash.
- salt: `string (optional)` - A custom salt to add randomness to the hash. If not provided, a fixed default salt is used.
- rounds: `number (optional)` - The number of hashing iterations to increase complexity. Default is `1000`.
Returns: `string` - A fixed-length hash string.
Example Code
Here are some examples demonstrating how to use the `TCH1.hash` function:
1. Basic Hashing
```javascript const TCH1 = require('tch1');
const input = "hello world"; const hash = TCH1.hash(input); console.log("Hash:", hash); ```
2. Custom Salt and Rounds
```javascript const TCH1 = require('tch1');
const input = "securePassword"; const customSalt = "MyS@lt12345"; const customRounds = 500; const hash = TCH1.hash(input, customSalt, customRounds); console.log("Custom Hash:", hash); ```
3. Using TCH1.js in Browser
```html
```
Frequently Created Bugs
1. "TCH1 is not defined."
Cause: The `tch1.js` file is not correctly included or imported in your project.
Solution: ```javascript // For CommonJS const TCH1 = require('tch1');
// For ES Modules import TCH1 from 'tch1'; ```
2. "Hash function is not returning the expected length."
Cause: The `HASH_LENGTH` in `tch1.js` might have been modified.
Solution: Verify that the `HASH_LENGTH` is set to your desired fixed size (default is 32 characters).
Additional Information
The `TCH1.hash` function provides a simple and efficient way to generate deterministic one-way hashes for your applications. It's lightweight and doesn't require any external dependencies, making it ideal for projects where minimizing dependencies is crucial.
For more advanced features or to customize the hashing process further, you can modify the `tch1.js` file to suit your specific requirements.
More Resources
Check out the API Overview for a deeper dive into available functions and customization options.
Feel free to explore and enhance TCH1.js to better fit your project's needs!