Shifty is a tiny zero-dependency secrets generator, built for the web using TypeScript.

Overview


Shifty Shifty



DeepSource DeepSource

Shifty is a tiny zero-dependency secrets generator, built for the web using TypeScript.

Installation

yarn add @deepsource/shifty

Usage

Shifty is built for the browser and won't work with Node. You can use the built-in crypto module instead.

import Shifty from "@deepsource/shifty";

const shifty = new Shifty((harden = true), (defaultLength = 16));
shifty.generate((length = 12)); // G8qZt7PEha^s

Options

Shifty
Parameter Default Description
harden true This flag enables adding special characters in the generated secret
defaultLength 16 Set the default length of the secrets generated
Shifty.generate
Parameter Default Description
length Shifty.defaultLength Length of the secret to be generated

How it works

The Web Crypto API is an interface allowing a script to use cryptographic primitives in order to build systems using cryptography. This library leverages the Web Crypto API to generate secrets and passwords for the web.

In case the browser does not support the Web Crypto API, the library uses a fallback, it generates the string using Math.random(). This is not cryptographically safe, but is still usable.

The algorithm for generating the password is quite simple

  1. Generate a array of 8-bit unsigned integers using Uint8Array
  2. Check if the browser crypto API is supported
    1. If the browser supports crypto, use the generate array as the seed to fill in with random values using window.crypto.getRandomValues
    2. Else use the fallback method, loop over the seed array, for every element, generate a random number between 0 to 255
  3. Initalize the secret string
  4. Start a while loop, until the length condition is matched
    1. Start a for loop over the generated numbers
    2. Convert the number to a character using String.fromCharCode
    3. If the character code is valid, append it to the secret string from step 3
    4. If the character limit is satisfied, break. Else, regenerate the seed array from step 2
  5. Return the generated string
You might also like...

A zero-dependency, buildless, terse, and type-safe way to write HTML in JavaScript.

hdot A sensible way to write HTML in JavaScript. Type-safe. Helps you follow the HTML spec. Terse. Almost character for character with plain HTML. Bui

Oct 24, 2022

Zero dependency profanity detector.

@cnakazawa/profane Zero dependency profanity detector based on Swearjar and Profane. Note: Some examples may contain offensive language for illustrati

Dec 28, 2022

Zero Dependency, Vanilla JavaScript Tag Editor

Zero Dependency, Vanilla JavaScript Tag Editor

_____ |_ _|___ ___ ___ ___ ___ | | | .'| . | . | -_| _| |_| |__,|_ |_ |___|_| |___|___| version 0.4.4 Tagger: Zero dependenc

Nov 25, 2022

Zero Two Bot,A fully Modular Whatsapp Bot to do everything possible in WhatsApp by Team Zero Two

Zero Two Bot,A fully Modular Whatsapp Bot to do everything possible in WhatsApp by Team Zero Two

🍭 𝗭𝗲𝗿𝗼 𝗧𝘄𝗼 𝗠𝗗 🍭 A Moduler WhatsApp Bot designed for both PM and Groups - To take your boring WhatsApp usage into a whole different level. T

Dec 25, 2022

Multiplies a number by zero. Useful for when you need to multiply a number by zero

multiply-by-zero Multiplies a number by zero. Useful for when you need to multiply a number by zero Please consider checking out the links of this pro

Jul 3, 2022

Obsidian text generator Plugin Text generator using GPT-3 (OpenAI)

Obsidian text generator Plugin Text generator using GPT-3 (OpenAI)

is a handy plugin for Obsidian that helps you generate text content using the powerful language model GP

Dec 29, 2022

Easily create key board shortcuts for your JS functions. Built using JS only with no other dependency. Inspired from MacOS spotlight

floodlightjs Inspired from macOS spotlight, floodlight is simple JS library that will show a search area. How the search is handled is completely on y

Aug 12, 2022

A tiny (108 bytes), secure, URL-friendly, unique string ID generator for JavaScript

A tiny (108 bytes), secure, URL-friendly, unique string ID generator for JavaScript

Nano ID English | Русский | 简体中文 | Bahasa Indonesia A tiny, secure, URL-friendly, unique string ID generator for JavaScript. “An amazing level of sens

Jan 8, 2023

A tiny, fast and fun static site generator for quick blogging

A tiny, fast and fun static site generator for quick blogging

1POST A tiny, fast and fun static site generator for quick blogging. 1POST is written entirely in NodeJS and has no dependencies. You can install as a

Dec 5, 2022
Comments
  • Reload buffer only when secret length is not reached

    Reload buffer only when secret length is not reached

    Description

    This change improves the secret generation algorithm by not calling the buffer population method when the secret length is met.

    Type of change

    Please delete options that are not relevant.

    • [x] Bug fix (non-breaking change which fixes an issue)
    • [ ] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
    • [ ] This change requires a documentation update

    Changes in this PR

    • Repositioned the populateBuffer method, to be called when the random buffer loop exits prematurely without completing the secret length

    Checklist before merging

    (Add to-do for reviewers and you to track, keep the PR in draft until all to-dos are cleared)

    • [ ] Tests
    • [ ] Code and Readme documentation

    Note to reviewers (Optional)

    (Anything that the reviewer should keep in mind)

    opened by souvik-deepsource 0
  • feat: update package.json for publishing

    feat: update package.json for publishing

    Description

    This PR has to following changes

    • Update org name to deepsource used on npmjs.com
    • Update package.json to include bugs, keywords, description, etc
    • Add banner to the built file

    Type of change

    Please delete options that are not relevant.

    • [x] Breaking change (fix or feature that would cause existing functionality to not work as expected)
    • [x] This change requires a documentation update

    Changes in this PR

    • Update name in package.json
    • Update docs in README

    Checklist before merging

    • [x] Code and Readme documentation
    opened by shivam-deepsource 0
  • fix: export parameters

    fix: export parameters

    This PR makes the following changes

    1. Export to index.* instead of shifty.*
    2. Set ES target version to 2018 instead of ESNext
    3. Update package name
    4. Update export files in package.json
    opened by shivam-deepsource 0
Releases(v1.0.0)
  • v1.0.0(Feb 23, 2022)

    Shifty 🥁

    Shifty is a tiny zero-dependency secrets generator, built for the web using TypeScript.

    What's Changed

    • feat: create pull request template [PLT-3907] by @shivam-deepsource in https://github.com/deepsourcelabs/shifty/pull/7
    • feat: update package.json for publishing by @shivam-deepsource in https://github.com/deepsourcelabs/shifty/pull/8
    • feat: add build action by @shivam-deepsource in https://github.com/deepsourcelabs/shifty/pull/9
    • feat: delete npmrc and favicon by @shivam-deepsource in https://github.com/deepsourcelabs/shifty/pull/10
    • chore: bump version to v1 by @shivam-deepsource in https://github.com/deepsourcelabs/shifty/pull/11
    • refactor: update tests to use nodeCrypto for mocks by @shivam-deepsource in https://github.com/deepsourcelabs/shifty/pull/12

    Full Changelog: https://github.com/deepsourcelabs/shifty/compare/v0.0.2...v1.0.0

    Source code(tar.gz)
    Source code(zip)
  • v0.0.2(Feb 23, 2022)

    Changes

    This release fixes exports, and has an updated readme with a fancy new logo.

    What's Changed

    • chore: add prettier by @shivam-deepsource in https://github.com/deepsourcelabs/shifty/pull/4
    • feat: Add logo to readme by @shivam-deepsource in https://github.com/deepsourcelabs/shifty/pull/5
    • fix: export parameters by @shivam-deepsource in https://github.com/deepsourcelabs/shifty/pull/6

    Full Changelog: https://github.com/deepsourcelabs/shifty/compare/v0.0.1...v0.0.2

    Source code(tar.gz)
    Source code(zip)
  • v0.0.1(Feb 8, 2022)

Owner
DeepSource
Automated code reviews for developers and engineering teams.
DeepSource
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
A back-end web app allows you to register and login to access a secrets page

A back-end web app allows you to register and login to access a secrets page

Shreya Christiana Malogi 12 Oct 30, 2022
A lightweight Adobe Photoshop .psd/.psb file parser in typescript with zero-dependency for WebBrowser and NodeJS

@webtoon/psd A lightweight Adobe Photoshop .psd/.psb file parser in typescript with zero-dependency for WebBrowser and NodeJS Browser Support Chrome F

null 830 Jan 1, 2023
Jsonup - This is a zero dependency compile-time JSON parser written in TypeScript

jsonup This is a zero dependency compile-time JSON parser written in TypeScript.

TANIGUCHI Masaya 39 Dec 8, 2022
A zero-dependency, strongly-typed web framework for Bun, Node and Cloudflare workers

nbit A simple, declarative, type-safe way to build web services and REST APIs for Bun, Node and Cloudflare Workers. Examples See some quick examples b

Simon Sturmer 16 Sep 16, 2022
Keep your sensitive information out of chat logs, emails, and more with heavily encrypted secrets.

Free encrypted secret sharing for everyone! This application is to be used to share encrypted secrets cross organizations, or as private persons. Hemm

Hemmelig 246 Dec 31, 2022
Zed Attack Proxy Scripts for finding CVEs and Secrets.

zap-scripts Zed Attack Proxy Scripts for finding CVEs and Secrets. Building This project uses Gradle to build the ZAP add-on, simply run: ./gradlew bu

Sepehrdad 115 Jan 3, 2023
Guardian - Securely Store and Share your Dev Secrets with your team

Guardian Securely Store and Share your Dev Secrets with your team Presentation About The Project No more sharing private development secrets over inef

Manavendra Sen 3 Oct 18, 2022
Dynamic, fast, accessible & zero dependency accordion for React

React Fast Accordion ⚡️ Dynamic, fast, accessible & zero dependency accordion for React How it's fast? Instead of adding event listener on all the ite

Shivam 59 Oct 8, 2022