From 852678e238eaa28199640b4b2a856e53d707ca24 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 3 Jan 2024 19:20:28 +0000 Subject: port multibase and jcsedssa2022 libs from streams --- Zotlabs/Lib/Multibase.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Zotlabs/Lib/Multibase.php (limited to 'Zotlabs/Lib/Multibase.php') diff --git a/Zotlabs/Lib/Multibase.php b/Zotlabs/Lib/Multibase.php new file mode 100644 index 000000000..099723630 --- /dev/null +++ b/Zotlabs/Lib/Multibase.php @@ -0,0 +1,34 @@ +encode($raw); + } + + public function secretKey($key) { + $base58 = new Base58(); + $raw = hex2bin('8026') . sodium_base642bin($key, SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING); + return 'z' . $base58->encode($raw); + } + + public function decode($key, $binary = false) { + $base58 = new Base58(); + $key = substr($key,1); + $raw = $base58->decode($key); + $binaryKey = substr($raw, 2); + return $binary ? $binaryKey : sodium_bin2base64($binaryKey, SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING); + } + +} -- cgit v1.2.3