-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhmac.html
653 lines (618 loc) · 20.6 KB
/
hmac.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>HMAC Hash Generator and Verifier Tool</title>
<meta
name="description"
content="A secure HMAC hash generator and verifier tool to enhance data protection. Generate and verify HMAC hashes for your passwords and sensitive data online."
/>
<meta
name="keywords"
content="hmac, hash generator, hash verifier, data encryption, secure passwords, hmac hashing"
/>
<link rel="canonical" href="https://bcrypt-tools.vercel.app/hmac" />
<!-- Favicon -->
<link
rel="apple-touch-icon"
sizes="180x180"
href="/images/favicon/apple-touch-icon.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="/images/favicon/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="/images/favicon/favicon-16x16.png"
/>
<link rel="manifest" href="/site.webmanifest" />
<link
rel="mask-icon"
href="/images/favicon/safari-pinned-tab.svg"
color="#5bbad5"
/>
<link rel="shortcut icon" href="/images/favicon/favicon.ico" />
<meta name="theme-color" content="#ffffff" />
<!-- Facebook Meta Tags -->
<meta property="og:url" content="https://bcrypt-tools.vercel.app/hmac" />
<meta property="og:type" content="website" />
<meta property="og:title" content="HMAC Hash Generator and Verifier Tool" />
<meta
property="og:description"
content="Securely generate and verify HMAC hashes online."
/>
<meta
property="og:image"
content="https://bcrypt-tools.vercel.app/images/social.png"
/>
<meta
property="og:image:alt"
content="An image featuring the text 'bcrypt.tools' in white on a blue background."
/>
<!-- Google Meta Tags -->
<meta name="google-adsense-account" content="ca-pub-7390955753222656" />
<script
async
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-7390955753222656"
crossorigin="anonymous"
></script>
<!-- Google tag (gtag.js) -->
<script
async
src="https://www.googletagmanager.com/gtag/js?id=G-NW49JN804Q"
></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", "G-NW49JN804Q");
</script>
<!-- Twitter Meta Tags -->
<meta name="twitter:card" content="summary_large_image" />
<meta
property="twitter:url"
content="https://bcrypt-tools.vercel.app/hmac"
/>
<meta
name="twitter:title"
content="HMAC Hash Generator and Verifier Tool"
/>
<meta
name="twitter:description"
content="Securely generate and verify HMAC hashes online."
/>
<meta
name="twitter:image"
content="https://bcrypt-tools.vercel.app/images/social.png"
/>
<meta
property="twitter:image:alt"
content="An image featuring the text 'bcrypt.tools' in white on a blue background."
/>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- hash-wasm API -->
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.umd.min.js"
async
crossorigin="anonymous"
></script>
<script>
const onSubmitGenerateHash = async (event) => {
event.preventDefault();
const text = document.getElementById("input-text").value;
const key = document.getElementById("input-key").value;
const algorithm = document.getElementById("algorithm").value;
if (!text || !key || !algorithm) {
showAlert("All fields are required!");
return;
}
try {
const hashFunc = hashwasm[algorithm]();
const hmac = await hashwasm.createHMAC(hashFunc, key);
hmac.init();
hmac.update(text);
const hash = hmac.digest();
document.getElementById("hash-output").value = hash;
document
.getElementById("hash-output")
.parentElement.classList.remove("hidden");
} catch (error) {
console.error(error);
showAlert("Error generating the hash!");
}
};
const onSubmitCompareHash = async (event) => {
event.preventDefault();
const data = document.getElementById("data-to-compare").value;
const key = document.getElementById("key-to-compare").value;
const algorithm = document.getElementById("algorithm-compare").value;
const hash = document.getElementById("hash-to-compare").value;
if (!data || !key || !hash || !algorithm) {
showAlert("All fields are required for comparison!");
return;
}
try {
const hashFunc = hashwasm[algorithm]();
const hmac = await hashwasm.createHMAC(hashFunc, key);
hmac.init();
hmac.update(data);
const computedHash = hmac.digest();
const isMatch = computedHash === hash;
const resultElement = document.getElementById("compare-hash-result");
resultElement.textContent = isMatch ? "Match" : "Do not match";
resultElement.classList.remove(
"bg-green-100",
"text-green-800",
"bg-red-100",
"text-red-800",
"border-green-400",
"border-red-400"
);
if (isMatch) {
resultElement.classList.add(
"bg-green-100",
"text-green-800",
"border-green-400"
);
} else {
resultElement.classList.add(
"bg-red-100",
"text-red-800",
"border-red-400"
);
}
resultElement.style.display = "block";
} catch (error) {
console.error("Error verifying the hash", error);
showAlert("Error verifying the hash!");
}
};
const copyToClipboard = () => {
const hashOutput = document.getElementById("hash-output");
navigator.clipboard
.writeText(hashOutput.value)
.then(() => showAlert("Hash copied to clipboard!"))
.catch((err) => console.error("Error copying to clipboard", err));
};
const pasteFromClipboard = () => {
navigator.clipboard
.readText()
.then((text) => {
const hashToCompareInput =
document.getElementById("hash-to-compare");
hashToCompareInput.value = text;
showAlert("Text pasted into the input!");
})
.catch((err) => {
console.error("Error pasting text from clipboard", err);
});
};
const showAlert = (message) => {
let existingAlert = document.querySelector(".alert-container");
if (existingAlert) {
existingAlert.remove();
}
const alertContainer = document.createElement("div");
alertContainer.textContent = message;
alertContainer.classList.add(
"alert-container",
"absolute",
"top-5",
"left-1/2",
"-translate-x-1/2",
"bg-blue-500",
"text-white",
"px-4",
"py-2",
"rounded",
"shadow-lg",
"transition-opacity",
"opacity-100"
);
document.body.appendChild(alertContainer);
setTimeout(() => {
alertContainer.classList.replace("opacity-100", "opacity-0");
}, 2500);
setTimeout(() => {
alertContainer.remove();
}, 3000);
};
const resetFirstForm = () => {
document.getElementById("generate-hash-form").reset();
document
.getElementById("hash-output")
.parentElement.classList.add("hidden");
};
const resetSecondForm = () => {
document.getElementById("compare-hash-form").reset();
document.getElementById("compare-hash-result").style.display = "none";
};
</script>
</head>
<body class="flex flex-col w-full bg-gray-100">
<div id="alert-container" class="hidden"></div>
<div
id="banner"
class="bg-blue-100 text-blue-800 border-b border-blue-300 py-2 text-sm"
>
<div class="container mx-auto text-center px-4">
<p>
<strong>Important Notice:</strong> This website's domain
<a
href="https://bcrypt.tools"
class="text-blue-600 underline hover:text-blue-800 font-semibold"
target="_blank"
>bcrypt.tools</a
>
will expire on <span class="font-semibold">February 19, 2025</span>.
We are migrating to our new domain:
<a
href="https://bcrypt-tools.vercel.app"
class="text-blue-600 underline hover:text-blue-800 font-semibold"
target="_blank"
>
bcrypt-tools.vercel.app
</a>
</p>
</div>
</div>
<header class="bg-white p-4">
<a href="/" class="hover:underline">
<h1 class="text-2xl font-bold text-center mb-2">
Bcrypt.tools - HMAC Hash Generator and Verifier Tool
</h1>
</a>
<p class="text-gray-600 text-center">
Easily generate and verify HMAC hashes for your passwords and sensitive
data online.
</p>
<nav class="mt-4">
<ul class="flex flex-wrap justify-center space-x-4">
<li>
<a href="/" class="text-blue-500 hover:text-blue-700">Bcrypt</a>
</li>
<li>
<a href="/md4" class="text-blue-500 hover:text-blue-700">MD4</a>
</li>
<li>
<a href="/md5" class="text-blue-500 hover:text-blue-700">MD5</a>
</li>
<li>
<a href="/sha1" class="text-blue-500 hover:text-blue-700">SHA-1</a>
</li>
<li>
<a href="/sha256" class="text-blue-500 hover:text-blue-700"
>SHA-256</a
>
</li>
<li>
<a href="/sha512" class="text-blue-500 hover:text-blue-700"
>SHA-512</a
>
</li>
<li>
<a href="/pbkdf2" class="text-blue-500 hover:text-blue-700"
>PBKDF2</a
>
</li>
<li>
<a href="/argon2" class="text-blue-500 hover:text-blue-700"
>Argon2</a
>
</li>
<li>
<a href="/crc32" class="text-blue-500 hover:text-blue-700">CRC32</a>
</li>
<li>
<a href="/hmac" class="text-blue-500 hover:text-blue-700 active"
>HMAC</a
>
</li>
</ul>
</nav>
</header>
<main class="mx-auto max-w-4xl p-4 flex flex-col gap-4">
<section id="hash-generator" class="bg-white border rounded-md p-4">
<h2 class="text-xl font-semibold mb-2">Encrypt</h2>
<p class="text-base mb-4 text-gray-700">
Generate a secure HMAC hash from any plaintext for enhanced password
protection.
</p>
<form
id="generate-hash-form"
onsubmit="onSubmitGenerateHash(event);"
class="mb-6"
>
<input
type="text"
id="input-text"
name="plaintext"
placeholder="Plain Text"
class="input"
required
/>
<input
type="text"
id="input-key"
name="key"
placeholder="Key"
class="input"
required
/>
<select id="algorithm" name="algorithm" class="input" required>
<option value="createSHA256">SHA-256</option>
<option value="createSHA512">SHA-512</option>
<option value="createMD5">MD5</option>
</select>
<div class="flex flex-col sm:flex-row justify-between gap-2">
<button type="submit" class="button button-solid">
Generate Hash
</button>
<button
type="button"
class="button button-solid"
onclick="resetFirstForm()"
>
Reset
</button>
</div>
</form>
<div class="flex items-center gap-2 hidden mb-4">
<input
type="text"
id="hash-output"
class="input flex-1"
style="margin-bottom: 0px"
readonly
/>
<button onclick="copyToClipboard()" class="button button-outline">
Copy
</button>
</div>
<h2 class="text-xl font-semibold mb-2">Verify</h2>
<p class="text-base mb-4 text-gray-700">
Verify if a plaintext matches a specific HMAC hash, ensuring secure
login validation.
</p>
<form id="compare-hash-form" onsubmit="onSubmitCompareHash(event);">
<input
type="text"
id="data-to-compare"
name="data-to-compare"
placeholder="Plain Text"
class="input"
required
/>
<input
type="text"
id="key-to-compare"
name="key-to-compare"
placeholder="Key"
class="input"
required
/>
<select
id="algorithm-compare"
name="algorithm"
class="input"
required
>
<option value="createSHA256">SHA-256</option>
<option value="createSHA512">SHA-512</option>
<option value="createMD5">MD5</option>
</select>
<div class="flex items-center gap-2 mb-4">
<input
type="text"
id="hash-to-compare"
name="hash-to-compare"
placeholder="Hash"
class="input"
style="margin-bottom: 0px"
required
/>
<button
type="button"
onclick="pasteFromClipboard()"
class="button button-outline"
>
Paste
</button>
</div>
<div class="flex flex-col sm:flex-row justify-between gap-2">
<button type="submit" class="button button-solid">
Verify Hash
</button>
<button
type="button"
class="button button-solid"
onclick="resetSecondForm()"
>
Reset
</button>
</div>
</form>
<div
id="compare-hash-result"
class="result"
style="display: none"
></div>
</section>
<section id="faq" class="flex flex-col gap-4">
<h2 class="text-xl font-semibold">FAQ - Frequently Asked Questions</h2>
<!-- About HMAC Section -->
<section
id="about-hmac"
class="flex flex-col bg-white border rounded-md p-4 gap-2"
>
<h3 class="text-lg font-semibold">What is HMAC?</h3>
<p class="text-base text-gray-700">
HMAC (Hash-based Message Authentication Code) is a specific type of
message authentication code (MAC) that involves a cryptographic hash
function and a secret cryptographic key. It is used to verify both
the data integrity and the authenticity of a message.
</p>
</section>
<!-- Hash Details Section -->
<section id="hash-info" class="bg-white border rounded-md p-4">
<h3 class="text-lg font-semibold mb-2">How HMAC Works</h3>
<p class="text-base text-gray-700 mb-4">
HMAC uses a combination of a hash function (such as SHA-256 or MD5)
and a secret key. The secret key is combined with the message using
a hashing algorithm to produce a hash value that can be used for
both verifying the integrity of the message and ensuring that it
hasn't been tampered with.
</p>
<p class="text-base text-gray-700 mb-4">
The result is a secure code that can be used to confirm that the
sender of the message had access to the shared secret key,
preventing forgeries.
</p>
</section>
<!-- Field Explanation Section -->
<section id="field-info" class="bg-white border rounded-md p-4">
<h3 class="text-lg font-semibold mb-2">Field Explanations</h3>
<p class="text-base text-gray-700 mb-4">
<strong>Key:</strong> The secret cryptographic key used in
combination with the hash function. The key ensures that only
someone with access to the key can verify the HMAC.
</p>
<p class="text-base text-gray-700 mb-4">
<strong>Message (Plain Text):</strong> The data or message you want
to protect with the HMAC. The hash function will be applied to this
message along with the secret key to generate the HMAC.
</p>
<p class="text-base text-gray-700 mb-4">
<strong>Hash Function:</strong> The cryptographic hash function used
to process the message and the key. Common hash functions used in
HMAC include SHA-256, SHA-512, and MD5.
</p>
</section>
<!-- Relevant Links Section -->
<section id="resources" class="flex flex-col gap-4">
<h2 class="text-xl font-semibold">Relevant Links</h2>
<div class="grid grid-cols-2 gap-4">
<div class="p-4 border rounded bg-white">
<a
href="https://en.wikipedia.org/wiki/HMAC"
target="_blank"
rel="external noopener noreferrer"
aria-label="Wikipedia page for HMAC - External link"
class="text-blue-600 hover:text-blue-800 hover:underline"
>
Wikipedia: HMAC
</a>
</div>
<div class="p-4 border rounded bg-white">
<a
href="https://tools.ietf.org/html/rfc2104"
target="_blank"
rel="external noopener noreferrer"
aria-label="RFC 2104 Specification - External link"
class="text-blue-600 hover:text-blue-800 hover:underline"
>
RFC 2104: HMAC Specification
</a>
</div>
</div>
</section>
</section>
</main>
<footer class="bg-gray-800 text-white p-4 mt-8">
<div
class="flex flex-col sm:flex-row max-w-6xl mx-auto flex flex-wrap justify-between items-center"
>
<div class="p-2 order-2 sm:order-first">
© 2025
<a
href="/"
class="text-white hover:text-gray-400"
rel="noopener noreferrer"
>Bcrypt.tools</a
>. All rights reserved.
</div>
<div class="p-2">
Email:
<a
href="mailto:[email protected]"
class="text-white hover:text-gray-400"
rel="noopener noreferrer"
>
</div>
<div class="p-2">
<a
href="/privacy-policy"
class="text-white hover:text-gray-400"
rel="noopener noreferrer"
>Privacy Policy</a
>
|
<a
href="/terms-of-use"
class="text-white hover:text-gray-400"
rel="noopener noreferrer"
>Terms of Use</a
>
</div>
</div>
</footer>
<style>
.input {
width: 100%;
padding: 0.5rem;
margin-bottom: 1rem;
border: 1px solid #ddd;
border-radius: 0.375rem;
box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);
}
.button {
padding: 0.5rem 1rem;
border-radius: 0.375rem;
font-weight: 600;
text-align: center;
cursor: pointer;
transition: all 0.3s ease;
}
.button-solid {
background-color: #4f46e5;
color: white;
border: 2px solid transparent;
}
.button-outline {
background-color: transparent;
color: #4f46e5;
border: 2px solid #4f46e5;
}
.button-outline:hover {
background-color: #4f46e5;
color: white;
}
.result {
padding: 0.5rem;
border-radius: 0.375rem;
margin-top: 1rem;
border-width: 1px;
}
.active {
font-weight: bold;
text-decoration: underline;
}
code {
padding: 0.25rem;
border-radius: 0.25rem;
word-break: break-all;
background-color: #f3f4f6;
}
</style>
</body>
</html>