Guest User

Untitled

a guest
Sep 7th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. list SEEDSET = ["", 0];
  2. string SEED_SALT;
  3. integer SEED_ROUNDS=1024;
  4.  
  5. GENERATE_SEED(string seed, string salt, integer rounds) {
  6.     SEEDSET = [STRETCH_KEY(seed, salt, rounds), 0];
  7. }
  8.  
  9. integer PRAND() {
  10.     integer index = llList2Integer(SEEDSET, 1);
  11.     string hash = llList2String(SEEDSET, 0);
  12.     if(index > 7) {
  13.         GENERATE_SEED(hash, SEED_SALT, SEED_ROUNDS);
  14.         return PRAND();
  15.     }
  16.     SEEDSET = [hash, index+1];
  17.     return (integer)("0x"+llGetSubString(hash, index*8, ((index+1)*8)-1));
  18. }
  19.  
  20. string STRETCH_KEY(string input, string salt, integer rounds) {
  21.     string hash = "";
  22.     for(rounds=rounds; rounds>=0; rounds--) {
  23.         hash = iwSHA256String(hash + input + salt);
  24.     }
  25.     return hash;
  26. }
Add Comment
Please, Sign In to add comment