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


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


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.


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.


                <!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 = "⇥";