Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b883b2a8df | ||
|
|
f336097b6a |
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sodium-javascript",
|
"name": "sodium-javascript",
|
||||||
"version": "0.5.1",
|
"version": "0.5.2",
|
||||||
"description": "WIP - a pure javascript version of sodium-native",
|
"description": "WIP - a pure javascript version of sodium-native",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
var assert = require('nanoassert')
|
var assert = require('nanoassert')
|
||||||
var randombytes = (function () {
|
var randombytes = (function () {
|
||||||
var QUOTA = 65536 // limit for QuotaExceededException
|
var QUOTA = 65536 // limit for QuotaExceededException
|
||||||
var crypto = typeof window !== 'undefined' ? (window.crypto || window.msCrypto) : null
|
var crypto = typeof global !== 'undefined' ? crypto = (global.crypto || global.msCrypto) : null
|
||||||
|
|
||||||
function windowBytes (out, n) {
|
function browserBytes (out, n) {
|
||||||
for (var i = 0; i < n; i += QUOTA) {
|
for (var i = 0; i < n; i += QUOTA) {
|
||||||
crypto.getRandomValues(out.subarray(i, i + Math.min(n - i, QUOTA)))
|
crypto.getRandomValues(out.subarray(i, i + Math.min(n - i, QUOTA)))
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ var randombytes = (function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (crypto && crypto.getRandomValues) {
|
if (crypto && crypto.getRandomValues) {
|
||||||
return windowBytes
|
return browserBytes
|
||||||
} else if (typeof require !== 'undefined') {
|
} else if (typeof require !== 'undefined') {
|
||||||
// Node.js.
|
// Node.js.
|
||||||
crypto = require('cry' + 'pto');
|
crypto = require('cry' + 'pto');
|
||||||
|
|||||||
Reference in New Issue
Block a user