Plugin Sync: Fix bug where Firefox has window.crypto but not window.crypto.getRandomValues

This commit is contained in:
Xelio 2013-05-08 21:27:41 +08:00
parent bf9fcd29e4
commit e02b0730dc

View File

@ -419,7 +419,7 @@ window.plugin.sync.searchFileOrFolder = function(queryOption, callback) {
// http://stackoverflow.com/a/7221797/2322660 // http://stackoverflow.com/a/7221797/2322660
// With format fixing: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where y in [8,9,a,b] // With format fixing: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where y in [8,9,a,b]
window.plugin.sync.generateUUID = function() { window.plugin.sync.generateUUID = function() {
if(window.crypto) { if(window.crypto && window.crypto.getRandomValues) {
var buf = new Uint16Array(8); var buf = new Uint16Array(8);
window.crypto.getRandomValues(buf); window.crypto.getRandomValues(buf);
var S4 = function(num) { var S4 = function(num) {