public class Hashids extends Object
This is implementation of http://hashids.org v1.0.0 version.
This implementation is immutable, thread-safe, no lock is necessary.
| 限定符和类型 | 字段和说明 |
|---|---|
static long |
MAX_NUMBER
Max number that can be encoded with Hashids.
|
| 构造器和说明 |
|---|
Hashids() |
Hashids(String salt) |
Hashids(String salt,
int minHashLength) |
Hashids(String salt,
int minHashLength,
String alphabet) |
| 限定符和类型 | 方法和说明 |
|---|---|
static int |
checkedCast(long value) |
long[] |
decode(String hash)
Decode string to numbers
|
String |
decodeHex(String hash)
Decode string to numbers
|
static Long |
decodeWithSnowFlake(Hashids hashids,
String encode)
将 hashid 恢复成 snowflake 数字
|
Long |
decodeWithSnowFlake(String encode)
将 hashid 恢复成 snowflake 数字
|
String |
encode(long... numbers)
Encode numbers to string
|
String |
encodeHex(String hexa)
Encode hexa to string
|
static String |
encodeWithSnowFlake(Hashids hashids,
Long snowFlake)
将 snowflake 数字转换为 hashid
|
String |
encodeWithSnowFlake(Long snowFlake)
将 snowflake 数字转换为 hashid
|
String |
getVersion()
Get Hashid algorithm version.
|
static void |
main(String[] args) |
public static final long MAX_NUMBER
public Hashids()
public Hashids(String salt)
public Hashids(String salt, int minHashLength)
public String encode(long... numbers)
numbers - the numbers to encodepublic long[] decode(String hash)
hash - the encoded stringpublic String encodeHex(String hexa)
hexa - the hexa to encodepublic String decodeHex(String hash)
hash - the encoded stringpublic static int checkedCast(long value)
public String getVersion()
public static void main(String[] args)
public static String encodeWithSnowFlake(Hashids hashids, Long snowFlake)
hashids - snowFlake - public String encodeWithSnowFlake(Long snowFlake)
snowFlake - public Long decodeWithSnowFlake(String encode)
encode - Copyright © 2019. All rights reserved.