fix: b582hex 里错误的调用了 bs58check

This commit is contained in:
陆柯 2021-11-16 09:57:02 +08:00
parent 50a88a7efd
commit 7fb2590670

View File

@ -1210,13 +1210,24 @@ class TICrypto {
* @param {*} hex * @param {*} hex
* @return {*} * @return {*}
* @memberof TICrypto * @memberof TICrypto
* 如果出现非HEX的字符从这个字符及其同Byte的另一个字符起直到末尾都会被忽略掉但仍然成功返回一个串
* bs58check bs58 可接受string, Buffer, ArrayBuffer, Array 包括空字符串'', 各种内容的数组例如包含 undefined{...}等等;
* 不可接受 undefined, null, {...}, 等等会返回 exception
*/ */
static hex2b58c(hex) { static hex2b58c(hex) {
try {
return bs58check.encode(Buffer.from(hex, 'hex')) return bs58check.encode(Buffer.from(hex, 'hex'))
} catch (exception) {
return null
}
} }
static hex2b58(hex) { static hex2b58(hex) {
try {
return bs58.encode(Buffer.from(hex, 'hex')) return bs58.encode(Buffer.from(hex, 'hex'))
} catch (exception) {
return null
}
} }
/** /**
@ -1237,7 +1248,7 @@ class TICrypto {
static b582hex(box) { static b582hex(box) {
try { try {
return bs58check.decode(box).toString('hex') return bs58.decode(box).toString('hex')
} catch (exception) { } catch (exception) {
return null return null
} }