index.js
function(length) {
    var charset = "abcdef0123456789";
    var i;
    var result = "";
    var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]';
    if(window.crypto && window.crypto.getRandomValues) {
        values = new Uint32Array(length);
        window.crypto.getRandomValues(values);
        for(i=0; i<length; i++) {
            result += charset[values[i] % charset.length];
        }
        return result;
    } else if(isOpera) {//Opera's Math.random is secure, see http://lists.w3.org/Archives/Public/public-webcrypto/2013Jan/0063.html
        for(i=0; i<length; i++) {
            result += charset[Math.floor(Math.random()*charset.length)];
        }
        return result;
    }
    else throw new Error("Your browser sucks and can't generate secure random numbers");
}
function(length) {
    var charset = "abcdef0123456789";
    var i;
    var result = "";
    var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]';
    if(window.crypto && window.crypto.getRandomValues) {
        values = new Uint32Array(length);
        window.crypto.getRandomValues(values);
        for(i=0; i<length; i++) {
            result += charset[values[i] % charset.length];
        }
        return result;
    } else if(isOpera) {//Opera's Math.random is secure, see http://lists.w3.org/Archives/Public/public-webcrypto/2013Jan/0063.html
        for(i=0; i<length; i++) {
            result += charset[Math.floor(Math.random()*charset.length)];
        }
        return result;
    }
    else throw new Error("Your browser sucks and can't generate secure random numbers");
}
function ( length ) { var charset = "abcdef0123456789" ; var i ; var result = "" ; var isOpera = Object . prototype . toString . call ( window . opera ) == '[object Opera]' ; if ( window . crypto && window . crypto . getRandomValues ) { values = new Uint32Array ( length ) ; window . crypto . getRandomValues ( values ) ; for ( i = 0 ; i < length ; i ++ ) { result += charset [ values [ i ] % charset . length ] ; } return result ; } else if ( isOpera ) { //Opera's Math.random is secure, see http://lists.w3.org/Archives/Public/public-webcrypto/2013Jan/0063.html for ( i = 0 ; i < length ; i ++ ) { result += charset [ Math . floor ( Math . random ( ) * charset . length ) ] ; } return result ; } else throw new Error ( "Your browser sucks and can't generate secure random numbers" ) ; }
Generate 16 random alpha numeric bytes.

@method (randomBytes)
@param {Number} length      The string length that should be generated
@return {String} A 16 char/UTF-8 byte string of random alpha-numeric characters
Generate 16 random alpha numeric bytes .