Class Base58Provider

java.lang.Object
org.miaixz.bus.core.codec.binary.provider.Base58Provider
All Implemented Interfaces:
Serializable, Decoder<CharSequence,byte[]>, Encoder<byte[],String>

public class Base58Provider extends Object implements Encoder<byte[],String>, Decoder<CharSequence,byte[]>, Serializable
Base58编码器 此编码器不包括校验码、版本等信息
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    单例
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    解码给定的Base58字符串
    static byte
    divmod(byte[] number, int firstDigit, int base, int divisor)
    将一个数字(表示为一个字节数组,每个字节包含指定基数的一位数字)除以给定的除数。 给定的数字被修改以包含商,返回值为余数。
    encode(byte[] data)
    Base58编码

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Base58Provider

      public Base58Provider()
  • Method Details

    • divmod

      public static byte divmod(byte[] number, int firstDigit, int base, int divisor)
      将一个数字(表示为一个字节数组,每个字节包含指定基数的一位数字)除以给定的除数。 给定的数字被修改以包含商,返回值为余数。
      Parameters:
      number - 要除的数
      firstDigit - 数组中第一个非零数字的索引(用于通过跳过前导零进行优化)
      base - 数字的位数表示基数(最多256)
      divisor - 要除以的数字(最多 256)
      Returns:
      除法运算的余数
    • encode

      public String encode(byte[] data)
      Base58编码
      Specified by:
      encode in interface Encoder<byte[],String>
      Parameters:
      data - 被编码的数据,不带校验和。
      Returns:
      编码后的字符串
    • decode

      public byte[] decode(CharSequence encoded) throws IllegalArgumentException
      解码给定的Base58字符串
      Specified by:
      decode in interface Decoder<CharSequence,byte[]>
      Parameters:
      encoded - Base58编码字符串
      Returns:
      解码后的bytes
      Throws:
      IllegalArgumentException - 非标准Base58字符串