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

crypto-random-string

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crypto-random-string - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

index.d.ts

6

index.js
'use strict';
const crypto = require('crypto');
module.exports = len => {
if (!Number.isFinite(len)) {
module.exports = length => {
if (!Number.isFinite(length)) {
throw new TypeError('Expected a finite number');
}
return crypto.randomBytes(Math.ceil(len / 2)).toString('hex').slice(0, len);
return crypto.randomBytes(Math.ceil(length / 2)).toString('hex').slice(0, length);
};
{
"name": "crypto-random-string",
"version": "1.0.0",
"description": "Generate a cryptographically strong random string",
"license": "MIT",
"repository": "sindresorhus/crypto-random-string",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"random",
"string",
"str",
"rand",
"text",
"id",
"identifier",
"slug",
"salt",
"crypto",
"strong",
"secure",
"hex"
],
"devDependencies": {
"ava": "*",
"xo": "*"
},
"xo": {
"esnext": true
}
"name": "crypto-random-string",
"version": "2.0.0",
"description": "Generate a cryptographically strong random string",
"license": "MIT",
"repository": "sindresorhus/crypto-random-string",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"random",
"string",
"text",
"id",
"identifier",
"slug",
"salt",
"crypto",
"strong",
"secure",
"hex"
],
"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
}
}

@@ -11,3 +11,3 @@ # crypto-random-string [![Build Status](https://travis-ci.org/sindresorhus/crypto-random-string.svg?branch=master)](https://travis-ci.org/sindresorhus/crypto-random-string)

```
$ npm install --save crypto-random-string
$ npm install crypto-random-string
```

@@ -30,2 +30,4 @@

Returns a [`hex`](https://en.wikipedia.org/wiki/Hexadecimal) string.
#### length

@@ -32,0 +34,0 @@

Sorry, the diff of this file is not supported yet

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