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

api_key_maker

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api_key_maker

  • 0.0.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

API Key Maker

Using SHA1 encryption and the current time, this gem generates a random string that is useful for API keys. The length of the string can be set as an attribute up to 39 characters in length. This is my attempt at creating a gem.

Installation

Add to your Gemfile and run the bundle command to install it.

gem "api_key_maker"

Requires Ruby 1.9.2 or later.

Usage

Whenever you need to generate a key, just call the following method:

ApiKeyMaker.make_api_key(10)

The first parameter tells what length you want the key to be. It defaults to 10 characters, but can go up to 39 characters in length.

If you want an attribute of a model to default to an api key, then just add the following in your model:

class ApiAccess < ActiveRecord::Base
  make_api_key :api_token, 13
end

This method takes 2 parameters. The first is the attribute that will be set to the api key. The second is the length (1-39 defaults to 10) of the string you want. This api key is generated before the model's validation.

Development

Questions or problems? Please post them on the issue tracker. You can contribute changes by forking the project and submitting a pull request. You can ensure the tests passing by running bundle and rake.

This gem is created by Johnathan Pulos and is under the MIT License.

FAQs

Package last updated on 26 Jan 2012

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