Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <body>
   <div class="container mt-5 pb-3 px-5">
      <form>
         <h1 class="text-center p-3 alert-info">
            <a href="trustdice.win" target="_blank" class="alert-link"> <u>TRUSTDICE.WIN</u></a> BET VERIFIER
         </h1>
         <div class="seed">
            <div class="input-group mb-3">
               <div class="input-group-prepend">
                  <span class="input-group-text"><b>Server Seed</b></span>
               </div>
               <input id="serverSeed" type="text" spellcheck="false" class="form-control">
            </div>
            <div class="input-group mb-3">
               <div class="input-group-prepend">
                  <span class="input-group-text"><b>Client Seed</b></span>
               </div>
               <input id="clientSeed" type="text" spellcheck="false" class="form-control">
            </div>
            <div class="form-check-inline">
               <label class="form-check-label">
               <input type="radio" id="eosAccount" class="form-check-input" name="optradio">EOS Account User
               </label>
            </div>
            <div class="form-check-inline">
               <label class="form-check-label">
               <input type="radio" id="regAccount" class="form-check-input" name="optradio">Register Account User
               </label>
            </div>
         </div>
         <hr class="my-4">
         <div class="result">
            <div class="input-group mb-3">
               <div class="input-group-prepend">
                  <span class="input-group-text"><b>Roll Result</b></span>
               </div>
               <input id="rollResult" type="text" class="form-control" disabled>
            </div>
            <div class="input-group">
               <div class="input-group-prepend">
                  <span class="input-group-text"><b>Jackpot Result</b></span>
               </div>
               <input id="jackpotResult" type="text" class="form-control" disabled>
            </div>
         </div>
      </form>
   </div>
</body>
              
            
!

CSS

              
                body {
  background-color: #d1ecf1;
}

.input-group-text {
  justify-content: flex-end
}

div.seed .input-group-text {
  width: 120px;
}

div.result .input-group-text {
  width: 140px;
}

div.seed,
div.result {
  padding: 20px 16px;
  border-radius: 3px;
}

div.seed {
  background: #90c2ea8c;
}

div.hash {
  background: #b1bcf794;
}

div.result {
  background: #e8a8a89e;
}
              
            
!

JS

              
                function resolveBet(serverSeed, clientSeed, salt) {
  let userSeedHash = sha1(clientSeed);
  let seed = serverSeed + userSeedHash + salt;
  let hash = sha512(seed);
  
  for(let i=0; i<24; i++) {
    lucky = parseInt(hash.substring(i * 5, i * 5 + 5), 16);
    if (lucky < 1000000) {
      return parseInt(lucky / 100) % 100 + 1;
    }
  }
  
  return 99;
}

function resolveJackpot(serverSeed, clientSeed, salt) {
  let userSeedHash = sha1(clientSeed);
  let seed = serverSeed + userSeedHash + salt;
  let hash = sha256(seed);
  let ret = 0,
      mod = 1000000000 + 7;

  for (let i = 0; i < 64; i++) {
    let sum = 0;
    for (let j = 0; j < 16; j++) {
      sum += ret;
      sum %= mod;
    }
    ret = (sum + parseInt(hash[i], 16)) % mod;
  }

  return parseInt(ret / 100) % 10000;
}

let $serverSeed = $('#serverSeed');
let $clientSeed = $('#clientSeed');
let $eosAccount = $('#eosAccount');
let $regAccount = $('#regAccount');
let $rollResult = $('#rollResult');
let $jackpotResult = $('#jackpotResult');

function updateResult() {
  let serverSeed = $serverSeed.val();
  let clientSeed = $clientSeed.val();
  let salt = "";
  
  if ($regAccount.is(":checked")) {
    salt = "trustdice";
  }
  else if ($eosAccount.is(":checked")) {
    salt = "";
  }
  else {
    $rollResult.val('<Empty User Type>');
    $jackpotResult.val('<Empty User Type>');
  }

  if (!serverSeed) {
    $rollResult.val('<Empty Server Seed>');
    $jackpotResult.val('<Empty Server Seed>');
  } else if (!clientSeed) {
    $rollResult.val('<Empty Client Seed>');
    $jackpotResult.val('<Empty Client Seed>');
  } else {
    let rollResult = resolveBet(serverSeed, clientSeed, salt);
    let jackpotResult = resolveJackpot(serverSeed, clientSeed, salt);
    $rollResult.val(rollResult);
    $jackpotResult.val(("" + jackpotResult).padStart(4, "0"));
  }
}

let query = URI(document.location.search).search(true)
$serverSeed.val(query.serverSeed);
$clientSeed.val(query.clientSeed);

if (query.accountFlag === "0") {
  $eosAccount.click();
}

if (query.accountFlag === "1") {
  $regAccount.click();
}

$eosAccount.on('click', updateResult);
$regAccount.on('click', updateResult);

$('form').keyup(updateResult).keyup();

              
            
!
999px

Console