java.lang.Object
org.seppiko.commons.utils.codec.Base62
- All Implemented Interfaces:
Serializable
Base62
A simple base62 encode / decode.
Similar to base64, typically used in URL shortness.
- Author:
- Leonard Woo
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic BigIntegerDecode Base62 string to numberstatic byte[]decodeToBytes(String str) Decode Base62 string to bytesstatic Stringencode(byte[] source) Encode bytes to Base62 stringstatic Stringencode(BigInteger source) Encode number to Base62 string
-
Method Details
-
encode
Encode bytes to Base62 string- Parameters:
source- bytes.- Returns:
- Base62 String.
- Throws:
IllegalArgumentException- source is empty.
-
encode
Encode number to Base62 string- Parameters:
source- Number.- Returns:
- Base62 String.
- Throws:
IllegalArgumentException- source is negative.
-
decodeToBytes
Decode Base62 string to bytes- Parameters:
str- Base62 String.- Returns:
- bytes.
- Throws:
IllegalArgumentException- source isnullor empty.
-
decode
Decode Base62 string to number- Parameters:
str- Base62 String.- Returns:
- Number.
- Throws:
IllegalArgumentException- string is empty ornull.
-