npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cipher-sys

v1.0.0

Published

A comprehensive utility package for encryption, decryption, and secure password management using Node.js and TypeScript, featuring key derivation, UUID generation, date formatting, and time conversion functions.

Downloads

84

Readme

Cipher System

Cipher System is a utility package built with Node.js and TypeScript, providing cryptographic functions, password management, and date/time manipulation utilities.

Features

  • Encryption & Decryption: Securely encrypt and decrypt text using AES-256-CBC.
  • Password Generation: Generate secure random passwords with customizable length and character sets.
  • Password Strength Validation: Check if a password meets defined strength criteria.
  • UUID Generation: Generate unique identifiers (UUIDs).
  • Date Formatting: Format dates according to specified locales and options.
  • Time Conversion: Convert time between hours, minutes, seconds, and milliseconds.

Installation

You can install the package via npm or yarn:

npm install cipher-sys
yarn add cipher-sys

Usage

Here's a brief overview of how to use the Cipher System.

Encryption and Decryption

import { Cipher } from 'cipher-sys';

const cipher = new Cipher();
const password = 'myPassword@';
const passKey = 'systemKey';

// Encrypting a password
const encrypted = cipher.encrypt(password, passKey); // String
console.log('Encrypted:', encrypted);

// Decrypting the password
const decrypted = cipher.decrypt(encrypted, passKey); // String
console.log('Decrypted:', decrypted);

Password Generation

const generatedPassword = cipher.generateSecurePassword(16); // String
console.log('Generated Password:', generatedPassword);

Password Strength Validation

const isStrong = cipher.isStrongPassword('P@ssw0rd123!', {
    minLength: 12,
    minUpperCase: 2,
    minNumbers: 2,
    minSpecialChar: 1
}); // Boolean

console.log('Is strong password:', isStrong);

Options:

| Option | Type | Default | Description | | ------------------------------- | -------- | ------- | ------------------------------------------------------------------ | | minLength | number | 8 | Minimum length of the password. | | maxLength | number | 20 | Maximum length of the password. | | minUpperCase | number | 1 | Minimum number of uppercase letters required. | | minLowerCase | number | 1 | Minimum number of lowercase letters required. | | minNumbers | number | 1 | Minimum number of numeric characters required. | | minSpecialChar | number | 1 | Minimum number of special characters required. | | minNonAlphaNumeric | number | 1 | Minimum number of non-alphanumeric characters required. | | minUniqueChars | number | 0 | Minimum number of unique characters required. | | minRepeatChars | number | 0 | Minimum number of repeated characters allowed. | | minConsecutiveChars | number | 0 | Minimum number of consecutive characters allowed. | | minConsecutiveNumeric | number | 0 | Minimum number of consecutive numeric characters allowed. | | minConsecutiveSpecialChar | number | 0 | Minimum number of consecutive special characters allowed. | | minConsecutiveNonAlphaNumeric | number | 0 | Minimum number of consecutive non-alphanumeric characters allowed. | | minConsecutiveUniqueChars | number | 0 | Minimum number of consecutive unique characters allowed. |

UUID Generation

const uuid = cipher.generateUUID(); // String
console.log('Generated UUID:', uuid);

Date Formatting

const formattedDate = cipher.formatDateWithLocale(new Date(), 'en-US', {
    year: 'numeric',
    month: 'long',
    day: 'numeric'
}); // String

console.log('Formatted Date:', formattedDate);

Options:

| Option | Type | Description | | -------------- | --------------------------------------------------------- | ---------------------------------------------------------------------- | | year | 'numeric', '2-digit' | Specifies the year format (full or 2-digit). | | month | 'numeric', '2-digit', 'long', 'short', 'narrow' | Specifies the month format (number, long name, short name, or narrow). | | day | 'numeric', '2-digit' | Specifies the day format (full or 2-digit). | | hour | 'numeric', '2-digit' | Specifies the hour format (12 or 24-hour format). | | minute | 'numeric', '2-digit' | Specifies the minute format (full or 2-digit). | | second | 'numeric', '2-digit' | Specifies the second format (full or 2-digit). | | timeZoneName | 'short', 'long' | Specifies the time zone name format (short or long). |

Time Conversion

const milliseconds = cipher.convertToMilliseconds(1, 30, 45); // String
console.log('Milliseconds:', milliseconds);

const time = cipher.convertFromMilliseconds(milliseconds); // Object { hours, minutes, seconds }
console.log('Converted Time:', time);

License

This project is licensed under the MIT License. See the LICENSE file for more information.

Contributing

Contributions are welcome! Please submit a pull request or open an issue to discuss changes.