add hex2b58 and b582hex
This commit is contained in:
13
index.js
13
index.js
@@ -3,6 +3,7 @@ const BigInt = require('big-integer') // 处理整数 https://github.com/peterol
|
||||
const crypto = require('crypto')
|
||||
const nacl = require('tweetnacl')
|
||||
const bs58check = require('bs58check')
|
||||
const bs58 = require('bs58') // bs58check depends on bs58
|
||||
const uuid = require('uuid')
|
||||
const keccak = require('keccak')
|
||||
const eccrypto = require('eccrypto-js') // 用于加解密。eccrypto 在 windows 上和 openssl 的版本兼容性有点麻烦,所以换用 eccrypto-js
|
||||
@@ -1214,6 +1215,10 @@ class TICrypto {
|
||||
return bs58check.encode(Buffer.from(hex, 'hex'))
|
||||
}
|
||||
|
||||
static hex2b58(hex) {
|
||||
return bs58.encode(Buffer.from(hex, 'hex'))
|
||||
}
|
||||
|
||||
/**
|
||||
* b58c 转十六进制
|
||||
*
|
||||
@@ -1230,6 +1235,14 @@ class TICrypto {
|
||||
}
|
||||
}
|
||||
|
||||
static b582hex(box) {
|
||||
try {
|
||||
return bs58check.decode(box).toString('hex')
|
||||
} catch (exception) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 十六进制转b64u
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user