https://github.com/christopheralphonse/passgen
Created this for fast ID creation for personal projects
https://github.com/christopheralphonse/passgen
passgenerator security uuid
Last synced: about 1 year ago
JSON representation
Created this for fast ID creation for personal projects
- Host: GitHub
- URL: https://github.com/christopheralphonse/passgen
- Owner: ChristopherAlphonse
- Created: 2024-04-11T02:58:15.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-19T03:40:51.000Z (almost 2 years ago)
- Last Synced: 2025-01-20T20:51:55.276Z (over 1 year ago)
- Topics: passgenerator, security, uuid
- Language: JavaScript
- Homepage:
- Size: 329 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# **PassGen**
The `PassGen` class utility designed to facilitate the generation of secure passwords and unique identifiers. It offers various methods for generating cryptographic hashes, secret keys, and unique IDs with customizable complexity levels.
### Methods
- **`hash(key: string): string`**
- **Description**: Generates a hash from the provided `key` combined with a timestamp. Returns a string in the specified base (`LEVEL`).
- **Parameters**:
- `key`: The input string to hash.
- **Returns**: A padded hash string.
- **`generateSecret(length: number = 32): string`**
- **Description**: Generates a random alphanumeric secret of the specified `length`.
- **Parameters**:
- `length` (optional): The length of the generated secret (default is 32).
- **Returns**: A random secret string.
- **`generateID(): string`**
- **Description**: Creates a unique identifier combining a hash, a UUID, and a random secret.
- **Returns**: A string in the format `hashValue-uuidValue-secretKey`.
## Running the code
```bash
yarn
```
*to see output*
```bash
yarn dev
```
## Usage Example
```js
const myPass = new PassGen(16);
const genID = myPass.generateID();
const hashValue = myPass.hash('this is a secret key?');
const secretKey = myPass.generateSecret();
console.log({ genID, hashValue, secretKey, myPass });
```
```bash
{
genID: '-7e9f954b-5794a534-9221-475a-842a-c7e8504fb509-Nprvndx',
hashValue: '2361ad49',
secretKey: 'zp9az7ljTw',
myPass: PassGen { value: 8191, LEVEL: 16, timestamp: 1724038646122n }
}
```