Skip to content

Commit

Permalink
Merge branch 'release/3.1.2-4'
Browse files Browse the repository at this point in the history
  • Loading branch information
evanvosberg committed Jun 19, 2014
2 parents 93b69a3 + aec0cb2 commit 7ddded8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Binary file modified build/crypto-js.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "crypto-js",
"title": "crypto-js",
"description": "Modularized port of googlecode project crypto-js.",
"version": "3.1.2-3",
"version": "3.1.2-4",
"homepage": "http://github.com/evanvosberg/crypto-js",
"author": {
"name": "Evan Vosberg",
Expand Down
23 changes: 21 additions & 2 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,27 @@ var CryptoJS = CryptoJS || (function (Math, undefined) {
*/
random: function (nBytes) {
var words = [];
for (var i = 0; i < nBytes; i += 4) {
words.push((Math.random() * 0x100000000) | 0);

var r = (function (m_w) {
var m_w = m_w;
var m_z = 0x3ade68b1;
var mask = 0xffffffff;

return function () {
m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;
m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;
var result = ((m_z << 0x10) + m_w) & mask;
result /= 0x100000000;
result += 0.5;
return result * (Math.random() > .5 ? 1 : -1);
}
});

for (var i = 0, rcache; i < nBytes; i += 4) {
var _r = r((rcache || Math.random()) * 0x100000000);

rcache = _r() * 0x3ade67b7;
words.push((_r() * 0x100000000) | 0);
}

return new WordArray.init(words, nBytes);
Expand Down

0 comments on commit 7ddded8

Please sign in to comment.