arnab

KalEl

Jun 8th, 2012
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     function InfiniteHash(code) {
  2.         var pool='';
  3.         var current=0;
  4.         var index=0;
  5.         // returns 0-256
  6.         this.getNext=function() {
  7.             if (pool.length<2) pool=SHA256(code+'|'+(index++).toString());
  8.             var result=parseInt(pool.substr(0,2),16);
  9.             pool=pool.substr(2);
  10.             return result;
  11.         }
  12.         // returns 0-limit, ignoring all that are higher than limit
  13.         this.getNextLimited=function(limit) {
  14.             var k;
  15.             while(true) {
  16.                 k=this.getNext();
  17.                 if (k<limit) return k;
  18.             }
  19.         }
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment