public class StringUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
Base64Digits |
static java.lang.String |
UrlSafeBase64Digits |
static java.nio.charset.Charset |
UTF8 |
Constructor and Description |
---|
StringUtil() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
base64Encode(byte[] data) |
static java.lang.String |
base64EncodeGeneric(java.lang.String digits,
byte[] data) |
static java.lang.String |
binaryToHex(byte[] data) |
static java.lang.String |
binaryToHex(byte[] data,
int offset,
int length)
Convert a string of binary bytes to the equivalent hexadecimal string.
|
static char |
hexDigit(int i) |
static java.lang.String |
javaQuotedLiteral(java.lang.String value)
Given a string, returns the representation of that string
as a Java string literal.
|
static java.lang.String |
javaQuotedLiterals(java.lang.Iterable<java.lang.String> value) |
static java.lang.String |
javaQuotedLiterals(java.lang.String[] value) |
static java.lang.String |
join(java.util.Collection<java.lang.String> strings,
java.lang.String delimiter) |
static java.lang.String |
jq(java.lang.Iterable<java.lang.String> value)
Shorthand for
javaQuotedLiterals(java.lang.String[]) . |
static java.lang.String |
jq(java.lang.String value)
Shorthand for
javaQuotedLiteral(java.lang.String) . |
static java.lang.String |
jq(java.lang.String[] value)
Shorthand for
javaQuotedLiterals(java.lang.String[]) . |
static boolean |
secureStringEquals(java.lang.String a,
java.lang.String b)
When you're comparing two strings for equality and one of them is a value that could be
provided by an attacker and the other is a value that the attacker shouldn't know, use
this function to check for equality.
|
static byte[] |
stringToUtf8(java.lang.String s) |
static java.lang.String |
urlSafeBase64Encode(byte[] data) |
static java.lang.String |
utf8ToString(byte[] utf8Data) |
static java.lang.String |
utf8ToString(byte[] utf8Data,
int offset,
int length) |
public static final java.nio.charset.Charset UTF8
public static final java.lang.String Base64Digits
public static final java.lang.String UrlSafeBase64Digits
public static char hexDigit(int i)
public static java.lang.String utf8ToString(byte[] utf8Data) throws java.nio.charset.CharacterCodingException
java.nio.charset.CharacterCodingException
public static java.lang.String utf8ToString(byte[] utf8Data, int offset, int length) throws java.nio.charset.CharacterCodingException
java.nio.charset.CharacterCodingException
public static byte[] stringToUtf8(java.lang.String s)
public static java.lang.String javaQuotedLiteral(java.lang.String value)
public static java.lang.String javaQuotedLiterals(java.lang.String[] value)
public static java.lang.String javaQuotedLiterals(java.lang.Iterable<java.lang.String> value)
public static java.lang.String jq(java.lang.String value)
javaQuotedLiteral(java.lang.String)
.public static java.lang.String jq(java.lang.String[] value)
javaQuotedLiterals(java.lang.String[])
.public static java.lang.String jq(java.lang.Iterable<java.lang.String> value)
javaQuotedLiterals(java.lang.String[])
.public static java.lang.String binaryToHex(byte[] data)
public static java.lang.String binaryToHex(byte[] data, int offset, int length)
public static boolean secureStringEquals(java.lang.String a, java.lang.String b)
String.equals
is not
secure.public static java.lang.String base64Encode(byte[] data)
public static java.lang.String urlSafeBase64Encode(byte[] data)
public static java.lang.String base64EncodeGeneric(java.lang.String digits, byte[] data)
public static java.lang.String join(java.util.Collection<java.lang.String> strings, java.lang.String delimiter)