Permalink
Browse files

[fix] utile.randomString now passes tests (and happens to technically…

… be base63 now)
  • Loading branch information...
1 parent 8bb807e commit 0350276584642e96c77f4f268dba31cdb5ca7576 @jfhbrook jfhbrook committed May 1, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/index.js
View
@@ -195,15 +195,15 @@ utile.randomString = function (length) {
// standard 4
mod = 4;
// default is 16
- bits = length * mod || 64;
+ bits = length * mod || 63;
// in v8, Math.random() yields 32 pseudo-random bits (in spidermonkey it gives 53)
while (bits > 0) {
// 32-bit integer
rand = Math.floor(Math.random() * 0x100000000);
//we use the top bits
for (i = 26; i > 0 && bits > 0; i -= mod, bits -= mod) {
- ret += chars[0x3F & rand >>> i];
+ ret += chars[0x3E & rand >>> i];
}
}

0 comments on commit 0350276

Please sign in to comment.