Skip to content
This repository
Browse code

Don't use uuid, just use crypto

  • Loading branch information...
commit 8f0f794690ecb5019f568ca90d6d1d5a824d282d 1 parent 18c9291
Isaac Z. Schlueter authored August 19, 2012
10  lib/adduser.js
... ...
@@ -1,18 +1,12 @@
1  
-
2 1
 module.exports = adduser
3 2
 
4  
-var uuid = require("node-uuid")
5  
-  , crypto
6  
-
7  
-try {
8  
-} catch (ex) {}
  3
+var crypto = require('crypto')
9 4
 
10 5
 function sha (s) {
11 6
   return crypto.createHash("sha1").update(s).digest("hex")
12 7
 }
13 8
 
14 9
 function adduser (username, password, email, cb) {
15  
-  if (!crypto) crypto = require("crypto")
16 10
 
17 11
   password = ("" + (password || "")).trim()
18 12
   if (!password) return cb(new Error("No password supplied."))
@@ -27,7 +21,7 @@ function adduser (username, password, email, cb) {
27 21
     "Sorry, ':' chars are not allowed in passwords.\n"+
28 22
     "See <https://issues.apache.org/jira/browse/COUCHDB-969> for why."))
29 23
 
30  
-  var salt = uuid()
  24
+  var salt = crypto.randomBytes(30).toString('hex')
31 25
     , userobj =
32 26
       { name : username
33 27
       , salt : salt
1  package.json
@@ -11,7 +11,6 @@
11 11
     "test": "tap test/*.js"
12 12
   },
13 13
   "dependencies": {
14  
-    "node-uuid": "~1.3.3",
15 14
     "request": "~2.9.202",
16 15
     "graceful-fs": "~1.1.8",
17 16
     "semver": "~1.0.14",

0 notes on commit 8f0f794

Please sign in to comment.
Something went wrong with that request. Please try again.