Use base-ex hex converter for base16 / correct fn name (#649)

This commit is contained in:
UmamiAppearance 2023-06-13 01:14:27 +02:00 committed by GitHub
parent c43bd21f8d
commit 054e836521
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}