SHA256
Переведены ключи UI в base58 и обновлены deploy defaults
This commit is contained in:
@@ -25,6 +25,33 @@ function base64UrlToBase64(value) {
|
||||
return normalized + '='.repeat(padLen);
|
||||
}
|
||||
|
||||
const BASE58_ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
||||
|
||||
export function bytesToBase58(bytes) {
|
||||
const input = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes || []);
|
||||
if (input.length === 0) return '';
|
||||
|
||||
const digits = [];
|
||||
for (let i = 0; i < input.length; i += 1) {
|
||||
let carry = input[i];
|
||||
for (let j = 0; j < digits.length; j += 1) {
|
||||
const value = (digits[j] * 256) + carry;
|
||||
digits[j] = value % 58;
|
||||
carry = Math.floor(value / 58);
|
||||
}
|
||||
while (carry > 0) {
|
||||
digits.push(carry % 58);
|
||||
carry = Math.floor(carry / 58);
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < input.length && input[i] === 0; i += 1) {
|
||||
digits.push(0);
|
||||
}
|
||||
|
||||
return digits.reverse().map((digit) => BASE58_ALPHABET[digit]).join('');
|
||||
}
|
||||
|
||||
export function randomBase64(byteLen = 32) {
|
||||
const bytes = getCryptoApi().getRandomValues(new Uint8Array(byteLen));
|
||||
return bytesToBase64(bytes);
|
||||
|
||||
Reference in New Issue
Block a user