Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- list SEEDSET = ["", 0];
- string SEED_SALT;
- integer SEED_ROUNDS=1024;
- GENERATE_SEED(string seed, string salt, integer rounds) {
- SEEDSET = [STRETCH_KEY(seed, salt, rounds), 0];
- }
- integer PRAND() {
- integer index = llList2Integer(SEEDSET, 1);
- string hash = llList2String(SEEDSET, 0);
- if(index > 7) {
- GENERATE_SEED(hash, SEED_SALT, SEED_ROUNDS);
- return PRAND();
- }
- SEEDSET = [hash, index+1];
- return (integer)("0x"+llGetSubString(hash, index*8, ((index+1)*8)-1));
- }
- string STRETCH_KEY(string input, string salt, integer rounds) {
- string hash = "";
- for(rounds=rounds; rounds>=0; rounds--) {
- hash = iwSHA256String(hash + input + salt);
- }
- return hash;
- }
Add Comment
Please, Sign In to add comment