代码拉取完成,页面将自动刷新
package dongle
import (
"bytes"
"math/big"
)
const base58table = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
// ByBase58 encodes by base58.
func (e encode) ByBase58() encode {
input, output := e.input, e.output
if input == nil {
return e
}
if output != nil {
input = output
}
var src []byte
intBytes := big.NewInt(0).SetBytes(input)
int0, int58 := big.NewInt(0), big.NewInt(58)
for intBytes.Cmp(big.NewInt(0)) > 0 {
intBytes.DivMod(intBytes, int58, int0)
src = append(src, string2bytes(base58table)[int0.Int64()])
}
e.output = reverseBytes(src)
return e
}
// ByBase58 encodes by base58.
func (d decode) ByBase58() decode {
input, output := d.input, d.output
if input == nil {
return d
}
if output != nil {
input = output
}
int0 := big.NewInt(0)
for _, val := range input {
index := bytes.IndexByte([]byte(base58table), val)
int0.Mul(int0, big.NewInt(58))
int0.Add(int0, big.NewInt(int64(index)))
}
d.output = int0.Bytes()
return d
}
// reverseBytes reverses byte slice.
func reverseBytes(b []byte) []byte {
for i := 0; i < len(b)/2; i++ {
b[i], b[len(b)-1-i] = b[len(b)-1-i], b[i]
}
return b
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。