public class Base58 extends Object
https://www.jianshu.com/p/ffc97c4d2306
在计算机系统中数值使用补码来表示和存储
原码(True form) :正数的原码为其二进制;负数的原码为对应的正数值在高位补1;
反码(1's complement):正数的反码与原码相同;负数的反码为其原码除符号位以外各位取反;
补码(2's complement):正数的补码与原码相同;负数的补码为其反码(最低位)加1;
补码系统的最大优点是可以在加法或减法处理中,不需因为数字的正负而使用不同的计算方式
计算机中只有加法,用两数补码相加,结果仍是补码表示
补码转原码:减1再取反
byte b = a byte number;
int i = b & 0xff; // 使得i与b的二进制补码一致
0xff is the bit length mask, calc bit length mask can use:
(1<<bits)-1 or -1L^(-1L<<bits)
Base58 code:except number 0, uppercase letter I and O, lowercase latter l
Reference from internet
| 构造器和说明 |
|---|
Base58() |
| 限定符和类型 | 方法和说明 |
|---|---|
static byte[] |
decode(String data)
Decodes the given base58 string into the original data bytes.
|
static byte[] |
decodeChecked(String data)
Decodes the given base58 string into the original data bytes, using the checksum in the
last 4 bytes of the decoded data to verify that the rest are correct.
|
static BigInteger |
decodeToBigInteger(String data)
base58 decode and construct BigInteger
|
static String |
encode(byte[] data)
Encodes the given bytes as a base58 string (no checksum is appended).
|
static String |
encodeChecked(byte[] data)
Encodes the given bytes as a base58 string (with appended checksum).
|
public static String encode(byte[] data)
data - the bytes to encodepublic static byte[] decode(String data)
data - the base58-encoded string to decodepublic static BigInteger decodeToBigInteger(String data)
data - the base58-encoded string to decodepublic static String encodeChecked(byte[] data)
data - the bytes to encodepublic static byte[] decodeChecked(String data)
data - the base58-encoded string to decode (which should include the checksum)Copyright © 2023. All rights reserved.