Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

token_checksum

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

token_checksum

  • 0.3.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

TokenChecksum

Generates a 30 character long random token, with a prefix and a 32-bit checksum in the last 6 digits. Inspired by:

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add token_checksum

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install token_checksum

Usage

token_one = TokenChecksum.generate("xoxo")
# "xoxo_3Q8oOwJyFzbuUaYIv2CPyu12K6gjmy2O8PIK"

# highly recommended that you introduce a secret as well
token_two = TokenChecksum.generate("xoxo", secret: "foo")
# "xoxo_4ftnAniunUKy6x0V75sMVg1VerpU2y1FoRT2"

# can also validate checksums
TokenChecksum.valid?(token_one)
# true

TokenChecksum.valid?(token_two, secret: "foo")
# true

TokenChecksum.valid?(token_two, secret: "bleh")
# FALSE

# can also validate on prefix
TokenChecksum.valid?(token_one)
# true

TokenChecksum.valid?(token_one, valid_prefixes: ["xoxo"])
# true

TokenChecksum.valid?(token_one, valid_prefixes: ["abcd"])
# FALSE

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 31 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc