Compare commits

...
7 Commits
Author SHA1 Message Date
Mathias Buus 5ccdcdee17 0.5.4 2017-11-19 13:16:51 +01:00
Mathias Buus 48081c6896 ignore crypto in the browser 2017-11-19 13:16:35 +01:00
Mathias Buus b1741bfdae 0.5.3 2017-11-17 12:09:34 +01:00
Mathias Buus f7de366eec fix shorthash_ready being deprecated 2017-11-17 12:07:52 +01:00
Mathias Buus 51e11143e5 fix siphash24 not having ready 2017-11-17 10:43:01 +01:00
Emil Bay b883b2a8df 0.5.2 2017-11-03 08:19:11 +01:00
Emil Bay f336097b6a Fix bug with undefined window in web workers
Fixes #8
2017-11-03 08:19:06 +01:00
3 changed files with 8 additions and 10 deletions
-5
View File
@@ -5,13 +5,8 @@ exports.crypto_shorthash_BYTES = siphash.BYTES
exports.crypto_shorthash_KEYBYTES = siphash.KEYBYTES
exports.crypto_shorthash_WASM_SUPPORTED = siphash.WASM_SUPPORTED
exports.crypto_shorthash_WASM_LOADED = siphash.WASM_LOADED
exports.crypto_shorthash_ready = siphash.ready
exports.crypto_shorthash = shorthash
siphash.ready(function () {
exports.crypto_shorthash_WASM_LOADED = siphash.WASM_LOADED
})
function shorthash (out, data, key, noAssert) {
siphash(data, key, out, noAssert)
}
+4 -1
View File
@@ -1,6 +1,6 @@
{
"name": "sodium-javascript",
"version": "0.5.1",
"version": "0.5.4",
"description": "WIP - a pure javascript version of sodium-native",
"main": "index.js",
"dependencies": {
@@ -14,6 +14,9 @@
"browserify": "^14.1.0",
"sodium-test": "^0.7.0"
},
"browser": {
"crypto": false
},
"scripts": {
"browser": "browserify test.js | browser-run",
"browser-manual": "browserify test.js | browser-run -p 1234",
+4 -4
View File
@@ -1,9 +1,9 @@
var assert = require('nanoassert')
var randombytes = (function () {
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) {
crypto.getRandomValues(out.subarray(i, i + Math.min(n - i, QUOTA)))
}
@@ -18,10 +18,10 @@ var randombytes = (function () {
}
if (crypto && crypto.getRandomValues) {
return windowBytes
return browserBytes
} else if (typeof require !== 'undefined') {
// Node.js.
crypto = require('cry' + 'pto');
crypto = require('crypto')
if (crypto && crypto.randomBytes) {
return nodeBytes
}