had a little oopsie with the toHex function

This commit is contained in:
Jurn Wubben 2025-11-11 15:46:50 +01:00
parent dbe3cb97b2
commit f8f59abf43
2 changed files with 2 additions and 2 deletions

View file

@ -7,7 +7,7 @@ import {
import { Device } from "./device.ts";
function toHex(data: Uint8Array): string {
return Array.from(data).map((b) => b.toString(16)).join("");
return Array.from(data).map((b) => b.toString(16).padStart(1, "0")).join("");
}
async function generateHMAC(key: string, message: string) {
const encoder = new TextEncoder();

View file

@ -82,7 +82,7 @@
<script>
function preventDefault(e) {alert(); e.preventDefault()}
function toHex(data) {
return Array.from(data).map((b) => b.toString(16)).join("");
return Array.from(data).map((b) => b.toString(16).padStart(1, "0")).join("");
}
async function generateHMAC(key, message) {
const encoder = new TextEncoder();