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