类 Hashids
java.lang.Object
io.eden.common.core.Hashids
public class Hashids
extends java.lang.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
-
字段概要
字段 修饰符和类型 字段 说明 static longMAX_NUMBERMax number that can be encoded with Hashids. -
构造器概要
-
方法概要
修饰符和类型 方法 说明 static intcheckedCast(long value)long[]decode(java.lang.String hash)Decode string to numbersjava.lang.StringdecodeHex(java.lang.String hash)Decode string to numbersstatic java.lang.LongdecodeWithSnowFlake(Hashids hashids, java.lang.String encode)将 hashid 恢复成 snowflake 数字java.lang.LongdecodeWithSnowFlake(java.lang.String encode)将 hashid 恢复成 snowflake 数字java.lang.Stringencode(long... numbers)Encode numbers to stringjava.lang.StringencodeHex(java.lang.String hexa)Encode hexa to stringstatic java.lang.StringencodeWithSnowFlake(Hashids hashids, java.lang.Long snowFlake)将 snowflake 数字转换为 hashidjava.lang.StringencodeWithSnowFlake(java.lang.Long snowFlake)将 snowflake 数字转换为 hashidjava.lang.StringgetVersion()Get Hashid algorithm version.
-
字段详细资料
-
MAX_NUMBER
public static final long MAX_NUMBERMax number that can be encoded with Hashids.- 另请参阅:
- 常量字段值
-
-
构造器详细资料
-
方法详细资料
-
encode
public java.lang.String encode(long... numbers)Encode numbers to string- 参数:
numbers- the numbers to encode- 返回:
- the encoded string
-
decode
public long[] decode(java.lang.String hash)Decode string to numbers- 参数:
hash- the encoded string- 返回:
- decoded numbers
-
encodeHex
public java.lang.String encodeHex(java.lang.String hexa)Encode hexa to string- 参数:
hexa- the hexa to encode- 返回:
- the encoded string
-
decodeHex
public java.lang.String decodeHex(java.lang.String hash)Decode string to numbers- 参数:
hash- the encoded string- 返回:
- decoded numbers
-
checkedCast
public static int checkedCast(long value) -
getVersion
public java.lang.String getVersion()Get Hashid algorithm version.- 返回:
- Hashids algorithm version implemented.
-
encodeWithSnowFlake
将 snowflake 数字转换为 hashid- 参数:
hashids-snowFlake-- 返回:
-
encodeWithSnowFlake
public java.lang.String encodeWithSnowFlake(java.lang.Long snowFlake)将 snowflake 数字转换为 hashid- 参数:
snowFlake-- 返回:
-
decodeWithSnowFlake
public java.lang.Long decodeWithSnowFlake(java.lang.String encode)将 hashid 恢复成 snowflake 数字- 参数:
encode-- 返回:
-
decodeWithSnowFlake
将 hashid 恢复成 snowflake 数字- 参数:
hashids-encode-- 返回:
-