fix: b582hex 里错误的调用了 bs58check
This commit is contained in:
parent
50a88a7efd
commit
7fb2590670
13
index.js
13
index.js
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user