Pen Settings

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <!DOCTYPE html>
<html lang="en">
  <meta charset="UTF-8">
    256-bit Hash Generator using Browser's Own SHA-256 Algorithm
  <div style="font-size: 2em">Paste Text Here&nbsp;
    <span style="font-size: .4em">
      If you type and don't paste a new nonce won't be created.
  <div id="inputForm">
    <textarea rows="20" cols="100" id="textImages" tabindex=0></textarea>
    <div id="nonce">
      <span style="font-size: 2em">
        Nonce = <textarea rows="1" cols="20" id="textNonce"
                          style="font-size:1.5em; color:red" tabindex=0>
      <input type="button" id="btnIncrement" value="++"
             title="Increment Nonce" tabindex=1 style="font-size:2em"/>
      <input type="button" id="btnCompleteHash" value="⇥"
             title="Find Correct Nonce" tabindex=2 style="font-size: 2em"/>
        If your Nonce says "Not a Number (NaN)", just put a number there.
  <div id="hash"></div>
  <div id="lsn"></div>
                  body {
      font-family: sans-serif
    #nonce {
      display: grid;
      height: 100px;
      align-items: center;
      grid-template-columns: repeat(6, 1fr);
      grid-template-rows: 100px;
    #nonce span {
      grid-column: 1 / 5;
    #nonce #btnIncrement {
      grid-column-start: 5;
    #nonce #cmp {
      grid-column-start: 6;
    #hash {
      color: darkblue;
      font-size: 1.425em;
      font-weight: 600;
      font-family: monospace;

              var el = document.getElementById("hash");
var hashHexValue = "";
var crypto = window.crypto || window.msCrypto;
var fieldNonce = document.getElementById("textNonce");
const difficulty = 3;

if (!crypto.subtle) { alert("Cryptography API not Supported") };

async function rollHash() {
  var promise = await crypto.subtle.digest({name: "SHA-256"}, str2ab(document.getElementById("textImages").value + fieldNonce.value));
  hashHexValue = ab2hex(promise);
  if (hashHexValue.substring(0, difficulty) == Array(difficulty + 1).join("0")) {
    document.getElementById("lsn").textContent = "LSN: " + hashHexValue + ", " + fieldNonce.value;

function ab2hex(buffer) { // buffer is an ArrayBuffer
  return Uint8Array(buffer), x => ('00' + x.toString(16)).slice(-2)).join('');

function ab2binary(buffer) { // buffer is an ArrayBuffer
  return Uint8Array(buffer), x => ('00000000' + x.toString(2)).slice(-8)).join('');

function ab2str(buf) {
  return String.fromCharCode.apply(null, new Uint16Array(buf));

function str2ab(str) {
  var buf = new ArrayBuffer(str.length*2); // 2 bytes for each char
  var bufView = new Uint16Array(buf);
  for (var i=0, strLen=str.length; i < strLen; i++) {
    bufView[i] = str.charCodeAt(i);
  return buf;

var buttonIncrement = document.getElementById("btnIncrement");
var buttonCompleteHash = document.getElementById("btnCompleteHash");

textImages.onpaste = function (event) {
  fieldNonce.value = -1;
  document.getElementById("hash").textContent = hashHexValue;

buttonIncrement.onclick = function () {
  fieldNonce.value = parseInt(fieldNonce.value) + 1;
  document.getElementById("hash").textContent = hashHexValue;

buttonCompleteHash.onclick = function () {
  if (document.getElementById("btnCompleteHash").value === "⇥") {
    document.getElementById("btnCompleteHash").value = "◼";
    intervalHundredths = window.setInterval (function () {
      fieldNonce.value = parseInt(fieldNonce.value) + 1;
    }, 0.1);
    intervalTenths = window.setInterval (function () {
      document.getElementById("hash").textContent = hashHexValue;
    }, 100);      
  } else {
    document.getElementById("btnCompleteHash").value = "⇥";
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.