Try something like this
//RNG.js // Generates a 16 byte block of random numbers using AES //RNG.js function RNG(){ this.key1=new Uint8Array(16); this.R=new Uint8Array(16); this.plain=new Uint8Array(16); }//end RNG RNG.prototype.random=function(A){ var i; E.srand(E.hwRand()); //randomize for(i=0;i<16;i++)this.plain[i]=(Math.random()*256)%256; this.R=AES.encrypt(this.plain,this.key1); for(i=0;i<16;i++)A[i]=this.R[i]; };//end random RNG.prototype.setup_random=function(){ for(var i=0;i<16;i++){ E.srand(E.hwRand()); this.key1[i]=parseInt((Math.random()*256),10); } };//end setup_random //exports = RNG; function testit(){ var i; var A=new Uint8Array(16); // var W=new (require("RNG"))(); var W=new RNG(); W.setup_random(); for(i=0;i<16;i++){ W.random(A); console.log(A); } } testit();
Thank you! @ClearMemory041063 I will try that.
@sureshkm started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Try something like this