Skip to content

Created this for fast ID creation for personal projects

Notifications You must be signed in to change notification settings

ChristopherAlphonse/PassGen

Repository files navigation

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

yarn 

to see output

yarn dev

Usage Example

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 });
{
  genID: '-7e9f954b-5794a534-9221-475a-842a-c7e8504fb509-Nprvndx',
  hashValue: '2361ad49',
  secretKey: 'zp9az7ljTw',
  myPass: PassGen { value: 8191, LEVEL: 16, timestamp: 1724038646122n }
}

About

Created this for fast ID creation for personal projects

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published