cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

bwJLjj

A Pen By Captain Anonymous

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div class="container">
  <h1>Bet Verifier</h1>
  <form>
    <div class="form-group">
      <label for="serverSeed">Server Seed</label>
      <input id="serverSeed" type="text" class="form-control">
    </div>
    <div class="form-group">
      <label for="clientSeed">Client Seed</label>
      <input id="clientSeed" type="text"  class="form-control">
    </div>
    <div class="form-group">
      <label for="nonce">Nonce</label>
      <input id="nonce" type="text" class="form-control">
    </div>
    <hr>
    <div class="form-group">
      <label for="serverSeedHash">Server Seed (Hashed)</label>
      <input id="serverSeedHash" type="text" class="form-control" disabled>
    </div>
    <div class="form-group">
      <label for="roll">Roll</label>
      <input id="roll" type="text" class="form-control" disabled>
    </div>
  </form>
</div>
            
          
!
            
              function getRoll(serverSeed, clientSeed, nonce) {
  var hash = sha512(serverSeed + clientSeed + nonce);
  var index = 0;
  do {
    var lucky = parseInt(hash.substr(index, 5), 16);
    index += 5;
  } while (lucky >= 1000000);
  return lucky % 10000;
}

var $serverSeed = $('#serverSeed');
var $clientSeed = $('#clientSeed');
var $nonce = $('#nonce');
var $serverSeedHash = $('#serverSeedHash');
var $roll = $('#roll');

var url = $.url(document.location.href);

$serverSeed.val(url.param('serverSeed'));
$clientSeed.val(url.param('clientSeed'));
$nonce.val(url.param('nonce'));

$('form').keyup(function() {
  var serverSeed = $serverSeed.val();
  var clientSeed = $clientSeed.val();
  var nonce = $nonce.val();

  $serverSeedHash.val(serverSeed ? sha256(serverSeed) : '<Empty Server Seed>');
  
  if (!serverSeed) {
    $roll.val('<Empty Server Seed>');
  } else if (!clientSeed) {
    $roll.val('<Empty Client Seed>');
  } else if (nonce === '') {
    $roll.val('<Empty Nonce>');
  } else {
    $roll.val(getRoll(serverSeed, clientSeed, nonce));
  }
}).keyup();
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console