From 054e83652150699d6918245223f4908ccd5a7033 Mon Sep 17 00:00:00 2001 From: UmamiAppearance <78618843+UmamiAppearance@users.noreply.github.com> Date: Tue, 13 Jun 2023 01:14:27 +0200 Subject: [PATCH] Use base-ex hex converter for base16 / correct fn name (#649) --- frontend/src/utils/hexToBase91.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/frontend/src/utils/hexToBase91.ts b/frontend/src/utils/hexToBase91.ts index 73955d3a..3eb5ccf0 100644 --- a/frontend/src/utils/hexToBase91.ts +++ b/frontend/src/utils/hexToBase91.ts @@ -1,10 +1,8 @@ -import { Base91 } from 'base-ex'; +import { Base16, Base91 } from 'base-ex'; -export default function hexToBase85(hex: string): string { - const hexes = hex.match(/.{1,2}/g); - if (hexes == null) return ''; - const byteArray = hexes.map((byte) => parseInt(byte, 16)); +export default function hexToBase91(hex: string): string { + const b16 = new Base16(); const b91 = new Base91(); - const base91string = b91.encode(new Uint8Array(byteArray)); + const base91string = b91.encode(b16.decode(hex)); return base91string; }