public class StringUtil extends Object
Modifier and Type | Field and Description |
---|---|
static String |
Base64Digits |
static String |
UrlSafeBase64Digits |
static Charset |
UTF8 |
Constructor and Description |
---|
StringUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
base64Encode(byte[] data) |
static String |
base64EncodeGeneric(String digits,
byte[] data) |
static String |
binaryToHex(byte[] data) |
static 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 String |
javaQuotedLiteral(String value)
Given a string, returns the representation of that string
as a Java string literal.
|
static String |
jq(String value)
Shorthand for
javaQuotedLiteral(java.lang.String) . |
static boolean |
secureStringEquals(String a,
String b)
When you're compating 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(String s) |
static String |
urlSafeBase64Encode(byte[] data) |
static String |
utf8ToString(byte[] utf8data) |
public static final Charset UTF8
public static final String Base64Digits
public static final String UrlSafeBase64Digits
public static char hexDigit(int i)
public static String utf8ToString(byte[] utf8data) throws CharacterCodingException
CharacterCodingException
public static byte[] stringToUtf8(String s)
public static String javaQuotedLiteral(String value)
public static String jq(String value)
javaQuotedLiteral(java.lang.String)
.public static String binaryToHex(byte[] data)
public static String binaryToHex(byte[] data, int offset, int length)
public static boolean secureStringEquals(String a, String b)
String.equals
is not
secure.public static String base64Encode(byte[] data)
public static String urlSafeBase64Encode(byte[] data)
Copyright © 2014. All rights reserved.