<h1>Verify Hash:</h1>
<input type="text" id="ticket" placeholder="Enter ticket">
<input type="text" id="secret" placeholder="Enter secret">
<button id="verify">Verify</button>

<p>Hash output: <br><span></span></p>

<h2>Check hash:</h2>
<input type="text" id="hash" placeholder="Enter hash"><button id="check">Check</button>

function createHash(ticket, secret) {
  var hash = forge_sha256(`${secret}:${ticket}`);
  return hash;
}

$("#verify").click(function () {
  $("span").text(createHash($("#ticket").val(), $("#secret").val()));
})

$("#check").click(function () {
  alert($("span").text() == $("#hash").val());
})
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js
  2. https://rawgit.com/brillout/forge-sha256/master/build/forge-sha256.min.js