fix: b582hex 里错误的调用了 bs58check
This commit is contained in:
parent
50a88a7efd
commit
7fb2590670
17
index.js
17
index.js
@ -1210,13 +1210,24 @@ class TICrypto {
|
||||
* @param {*} hex
|
||||
* @return {*}
|
||||
* @memberof TICrypto
|
||||
* 如果出现非HEX的字符,从这个字符(及其同Byte的另一个字符)起直到末尾,都会被忽略掉,但仍然成功返回一个串。
|
||||
* bs58check 和 bs58 可接受string, Buffer, ArrayBuffer, Array (包括空字符串'', 各种内容的数组例如包含 undefined,{...},等等);
|
||||
* 不可接受 undefined, null, {...}, 等等,会返回 exception
|
||||
*/
|
||||
static hex2b58c(hex) {
|
||||
return bs58check.encode(Buffer.from(hex, 'hex'))
|
||||
try {
|
||||
return bs58check.encode(Buffer.from(hex, 'hex'))
|
||||
} catch (exception) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
static hex2b58(hex) {
|
||||
return bs58.encode(Buffer.from(hex, 'hex'))
|
||||
try {
|
||||
return bs58.encode(Buffer.from(hex, 'hex'))
|
||||
} catch (exception) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1237,7 +1248,7 @@ class TICrypto {
|
||||
|
||||
static b582hex(box) {
|
||||
try {
|
||||
return bs58check.decode(box).toString('hex')
|
||||
return bs58.decode(box).toString('hex')
|
||||
} catch (exception) {
|
||||
return null
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user