/** * Creates a {@code HashCode} from a hexadecimal ({@code base 16}) encoded string. The string must * be at least 2 characters long, and contain only valid, lower-cased hexadecimal characters. * * <p>This method accepts the exact format generated by {@link #toString}. If you require more * lenient {@code base 16} decoding, please use {@link com.google.common.io.BaseEncoding#decode} * (and pass the result to {@link #fromBytes}). * * @since 15.0 */ public static HashCode fromString(String string) { checkArgument( string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument( string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); }
/** * Creates a {@code HashCode} from a hexadecimal ({@code base 16}) encoded string. The string must * be at least 2 characters long, and contain only valid, lower-cased hexadecimal characters. * * <p>This method accepts the exact format generated by {@link #toString}. If you require more * lenient {@code base 16} decoding, please use {@link com.google.common.io.BaseEncoding#decode} * (and pass the result to {@link #fromBytes}). * * @since 15.0 */ public static HashCode fromString(String string) { checkArgument( string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument( string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); }
/** * Creates a {@code HashCode} from a hexadecimal ({@code base 16}) encoded string. The string must * be at least 2 characters long, and contain only valid, lower-cased hexadecimal characters. * * <p>This method accepts the exact format generated by {@link #toString}. If you require more * lenient {@code base 16} decoding, please use {@link com.google.common.io.BaseEncoding#decode} * (and pass the result to {@link #fromBytes}). * * @since 15.0 */ public static HashCode fromString(String string) { checkArgument( string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument( string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); }
/** * Creates a {@code HashCode} from a hexadecimal ({@code base 16}) encoded string. The string must * be at least 2 characters long, and contain only valid, lower-cased hexadecimal characters. * * <p>This method accepts the exact format generated by {@link #toString}. If you require more * lenient {@code base 16} decoding, please use * {@link com.google.common.io.BaseEncoding#decode} (and pass the result to {@link #fromBytes}). * * @since 15.0 */ public static HashCode fromString(String string) { checkArgument(string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument(string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); }
/** * Creates a {@code HashCode} from a hexadecimal ({@code base 16}) encoded string. The string must * be at least 2 characters long, and contain only valid, lower-cased hexadecimal characters. * * <p>This method accepts the exact format generated by {@link #toString}. If you require more * lenient {@code base 16} decoding, please use * {@link com.google.common.io.BaseEncoding#decode} (and pass the result to {@link #fromBytes}). * * @since 15.0 */ public static HashCode fromString(String string) { checkArgument(string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument(string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); }
/** * Creates a {@code HashCode} from a hexadecimal ({@code base 16}) encoded string. The string must * be at least 2 characters long, and contain only valid, lower-cased hexadecimal characters. * * <p>This method accepts the exact format generated by {@link #toString}. If you require more * lenient {@code base 16} decoding, please use * {@link com.google.common.io.BaseEncoding#decode} (and pass the result to {@link #fromBytes}). * * @since 15.0 */ public static HashCode fromString(String string) { checkArgument(string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument(string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); }
/** * Creates a {@code HashCode} from a hexadecimal ({@code base 16}) encoded string. The string must * be at least 2 characters long, and contain only valid, lower-cased hexadecimal characters. * * <p>This method accepts the exact format generated by {@link #toString}. If you require more * lenient {@code base 16} decoding, please use {@link com.google.common.io.BaseEncoding#decode} * (and pass the result to {@link #fromBytes}). * * @since 15.0 */ public static HashCode fromString(String string) { checkArgument( string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument( string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); }
/** * Creates a {@code HashCode} from a hexadecimal ({@code base 16}) encoded string. The string must * be at least 2 characters long, and contain only valid, lower-cased hexadecimal characters. * * <p>This method accepts the exact format generated by {@link #toString}. If you require more * lenient {@code base 16} decoding, please use * {@link com.google.common.io.BaseEncoding#decode} (and pass the result to {@link #fromBytes}). * * @since 15.0 */ public static HashCode fromString(String string) { checkArgument(string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument(string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); }
/** * Creates a {@code HashCode} from a hexadecimal ({@code base 16}) encoded string. The string must * be at least 2 characters long, and contain only valid, lower-cased hexadecimal characters. * * <p>This method accepts the exact format generated by {@link #toString}. If you require more * lenient {@code base 16} decoding, please use * {@link com.google.common.io.BaseEncoding#decode} (and pass the result to {@link #fromBytes}). * * @since 15.0 */ public static HashCode fromString(String string) { checkArgument(string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument(string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); }
/** * Creates a {@code HashCode} from a hexadecimal ({@code base 16}) encoded string. The string must * be at least 2 characters long, and contain only valid, lower-cased hexadecimal characters. * * <p>This method accepts the exact format generated by {@link #toString}. If you require more * lenient {@code base 16} decoding, please use * {@link com.google.common.io.BaseEncoding#decode} (and pass the result to {@link #fromBytes}). * * @since 15.0 */ public static HashCode fromString(String string) { checkArgument(string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument(string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); }
/** * Creates a {@code HashCode} from a hexadecimal ({@code base 16}) encoded string. The string must * be at least 2 characters long, and contain only valid, lower-cased hexadecimal characters. * * <p>This method accepts the exact format generated by {@link #toString}. If you require more * lenient {@code base 16} decoding, please use {@link com.google.common.io.BaseEncoding#decode} * (and pass the result to {@link #fromBytes}). * * @since 15.0 */ public static HashCode fromString(String string) { checkArgument( string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument( string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); }