类 Hashids

java.lang.Object
io.eden.common.core.Hashids

public class Hashids
extends Object
Hashids designed for Generating short hashes from numbers (like YouTube and Bitly), obfuscate database IDs, use them as forgotten password hashes, invitation codes, store shard numbers.

This is implementation of http://hashids.org v1.0.0 version.

This implementation is immutable, thread-safe, no lock is necessary.

从以下版本开始:
0.3.3
作者:
fanweixiao, Tercio Gaudencio Filho, Eden Lee
  • 字段详细资料

    • MAX_NUMBER

      public static final long MAX_NUMBER
      Max number that can be encoded with Hashids.
      另请参阅:
      常量字段值
  • 构造器详细资料

    • Hashids

      public Hashids()
    • Hashids

      public Hashids​(String salt)
    • Hashids

      public Hashids​(String salt, int minHashLength)
    • Hashids

      public Hashids​(String salt, int minHashLength, String alphabet)
  • 方法详细资料

    • encode

      public String encode​(long... numbers)
      Encode numbers to string
      参数:
      numbers - the numbers to encode
      返回:
      the encoded string
    • decode

      public long[] decode​(String hash)
      Decode string to numbers
      参数:
      hash - the encoded string
      返回:
      decoded numbers
    • encodeHex

      public String encodeHex​(String hexa)
      Encode hexa to string
      参数:
      hexa - the hexa to encode
      返回:
      the encoded string
    • decodeHex

      public String decodeHex​(String hash)
      Decode string to numbers
      参数:
      hash - the encoded string
      返回:
      decoded numbers
    • checkedCast

      public static int checkedCast​(long value)
    • getVersion

      public String getVersion()
      Get Hashid algorithm version.
      返回:
      Hashids algorithm version implemented.
    • encodeWithSnowFlake

      public static String encodeWithSnowFlake​(Hashids hashids, Long snowFlake)
      将 snowflake 数字转换为 hashid
      参数:
      hashids -
      snowFlake -
      返回:
    • encodeWithSnowFlake

      public String encodeWithSnowFlake​(Long snowFlake)
      将 snowflake 数字转换为 hashid
      参数:
      snowFlake -
      返回:
    • decodeWithSnowFlake

      public Long decodeWithSnowFlake​(String encode)
      将 hashid 恢复成 snowflake 数字
      参数:
      encode -
      返回:
    • decodeWithSnowFlake

      public static Long decodeWithSnowFlake​(Hashids hashids, String encode)
      将 hashid 恢复成 snowflake 数字
      参数:
      hashids -
      encode -
      返回: