Generate SHA-256 Hash Locally

by islam ayoub

HTML

<div class="utilvo-card">
  <div class="header">
    <div class="badge">đź”’ 100% Client-Side</div>
    <h2>Utilvo Instant Hash & Privacy Tool</h2>
    <p>Zero-server cryptographic hash generation running entirely in your browser memory.</p>
  </div>

  <div class="input-group">
    <label for="input-text">Enter Text or Secret Key:</label>
    <textarea id="input-text" placeholder="Type or paste any text to hash locally..." rows="3">Hello from Utilvo! Fast, private client-side utilities.</textarea>
  </div>

  <div class="output-group">
    <div class="output-header">
      <span>SHA-256 Hash (Hex):</span>
      <span id="speed-tag" class="speed">0 ms</span>
    </div>
    <div class="hash-box" id="hash-output">Calculating...</div>
  </div>

  <div class="footer">
    <span>Engineered by </span>
    <a href="https://utilvo.com" target="_blank" rel="noopener">Utilvo — Free Client-Side Utilities</a>
  </div>
</div>

CSS

body {
  margin: 0;
  padding: 24px;
  background-color: #0b0f19;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #f1f5f9;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80vh;
}

.utilvo-card {
  background: #111827;
  border: 1px solid #1e293b;
  border-radius: 16px;
  padding: 28px;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.badge {
  display: inline-block;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 9999px;
  margin-bottom: 10px;
}

.header h2 {
  margin: 0 0 6px 0;
  font-size: 20px;
  color: #f8fafc;
}

.header p {
  margin: 0 0 20px 0;
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.5;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 8px;
}

textarea {
  width: 100%;
  box-sizing: border-box;
  background: #0b0f19;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 10px 12px;
  color: #f1f5f9;
  font-size: 13px;
  resize: vertical;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}

textarea:focus {
  border-color: #6366f1;
}

.output-group {
  margin-top: 18px;
}

.output-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  margin-bottom: 6px;
}

.speed {
  color: #10b981;
}

.hash-box {
  background: #030712;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 12px;
  font-family: monospace;
  font-size: 12px;
  color: #38bdf8;
  word-break: break-all;
  line-height: 1.4;
  user-select: all;
}

.footer {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid #1e293b;
  font-size: 12px;
  color: #64748b;
 ...

JavaScript

async function computeSha256(text) {
  const start = performance.now();
  const encoder = new TextEncoder();
  const data = encoder.encode(text);
  const hashBuffer = await crypto.subtle.digest("SHA-256", data);
  const hashArray = Array.from(new Uint8Array(hashBuffer));
  const hashHex = hashArray.map(b => b.toString(16).padStart(2, "0")).join("");
  const duration = (performance.now() - start).toFixed(2);
  return { hash: hashHex, duration: duration };
}

const input = document.getElementById("input-text");
const output = document.getElementById("hash-output");
const speedTag = document.getElementById("speed-tag");

async function updateHash() {
  const text = input.value;
  if (!text) {
    output.textContent = "Enter text above...";
    speedTag.textContent = "0 ms";
    return;
  }
  const result = await computeSha256(text);
  output.textContent = result.hash;
  speedTag.textContent = `${result.duration} ms (Instant)`;
}

input.addEventListener("input", updateHash);
updateHash();