Class Base62Provider

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

public class Base62Provider extends Object implements Encoder<byte[],byte[]>, Decoder<byte[],byte[]>, Serializable
Base62编码解码实现,常用于短URL From https://github.com/seruco/base62
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    单例
    static final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    convert(byte[] message, int sourceBase, int targetBase)
    使用定义的字母表从源基准到目标基准
    byte[]
    decode(byte[] encoded)
    解码Base62消息
    byte[]
    decode(byte[] encoded, boolean useInverted)
    解码Base62消息
    byte[]
    encode(byte[] data)
    编码指定消息bytes为Base62格式的bytes
    byte[]
    encode(byte[] data, boolean useInverted)
    编码指定消息bytes为Base62格式的bytes
    static byte[]
    translate(byte[] indices, byte[] dictionary)
    按照字典转换bytes

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • Base62Provider

      public Base62Provider()
  • Method Details

    • translate

      public static byte[] translate(byte[] indices, byte[] dictionary)
      按照字典转换bytes
      Parameters:
      indices - 内容
      dictionary - 字典
      Returns:
      转换值
    • convert

      public static byte[] convert(byte[] message, int sourceBase, int targetBase)
      使用定义的字母表从源基准到目标基准
      Parameters:
      message - 消息bytes
      sourceBase - 源基准长度
      targetBase - 目标基准长度
      Returns:
      计算结果
    • encode

      public byte[] encode(byte[] data)
      编码指定消息bytes为Base62格式的bytes
      Specified by:
      encode in interface Encoder<byte[],byte[]>
      Parameters:
      data - 被编码的消息
      Returns:
      Base62内容
    • encode

      public byte[] encode(byte[] data, boolean useInverted)
      编码指定消息bytes为Base62格式的bytes
      Parameters:
      data - 被编码的消息
      useInverted - 是否使用反转风格,即将GMP风格中的大小写做转换
      Returns:
      Base62内容
    • decode

      public byte[] decode(byte[] encoded)
      解码Base62消息
      Specified by:
      decode in interface Decoder<byte[],byte[]>
      Parameters:
      encoded - Base62内容
      Returns:
      消息
    • decode

      public byte[] decode(byte[] encoded, boolean useInverted)
      解码Base62消息
      Parameters:
      encoded - Base62内容
      useInverted - 是否使用反转风格,即将GMP风格中的大小写做转换
      Returns:
      消息