1// prng4.js - uses Arcfour as a PRNG 2 3function Arcfour() { 4 this.i = 0; 5 this.j = 0; 6 this.S = new Array(); 7} 8 9// Initialize arcfour context from key, an array of ints, each from [0..255] 10function ARC4init(key) { 11 var i, j, t; 12 for(i = 0; i < 256; ++i) 13 this.S[i] = i; 14 j = 0; 15 for(i = 0; i < 256; ++i) { 16 j = (j + this.S[i] + key[i % key.length]) & 255; 17 t = this.S[i]; 18 this.S[i] = this.S[j]; 19 this.S[j] = t; 20 } 21 this.i = 0; 22 this.j = 0; 23} 24 25function ARC4next() { 26 var t; 27 this.i = (this.i + 1) & 255; 28 this.j = (this.j + this.S[this.i]) & 255; 29 t = this.S[this.i]; 30 this.S[this.i] = this.S[this.j]; 31 this.S[this.j] = t; 32 return this.S[(t + this.S[this.i]) & 255]; 33} 34 35Arcfour.prototype.init = ARC4init; 36Arcfour.prototype.next = ARC4next; 37 38// Plug in your RNG constructor here 39function prng_newstate() { 40 return new Arcfour(); 41} 42 43// Pool size must be a multiple of 4 and greater than 32. 44// An array of bytes the size of the pool will be passed to init() 45var rng_psize = 256;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.