From f2afab4b1b43a26136f7340e03b8eec0b1495646 Mon Sep 17 00:00:00 2001 From: Deirdre Connolly Date: Mon, 8 Jun 2015 14:22:39 -0400 Subject: [PATCH] If browser `crypto` is not available, try `msCrypto` before assuming a Node environment --- src/libsodium/randombytes/randombytes.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libsodium/randombytes/randombytes.c b/src/libsodium/randombytes/randombytes.c index 53a7a2fc..014ad161 100644 --- a/src/libsodium/randombytes/randombytes.c +++ b/src/libsodium/randombytes/randombytes.c @@ -60,7 +60,8 @@ randombytes_stir(void) EM_ASM({ if (Module.getRandomValue === undefined) { try { - var crypto_ = ("object" === typeof window ? window : self).crypto, + var window_ = "object" === typeof window ? window : self, + crypto_ = typeof window_.crypto !== "undefined" ? window_.crypto : window_.msCrypto, randomValuesStandard = function() { var buf = new Uint32Array(1); crypto_.getRandomValues(buf);