1 // Copyright (C) 2011 - Will Glozer. All rights reserved.
3 package com.lambdaworks.crypto.test;
5 public class CryptoTestUtil {
6 public static byte[] decode(String str) {
7 byte[] bytes = new byte[str.length() / 2];
10 for (int i = 0; i < str.length(); i += 2) {
11 int high = hexValue(str.charAt(i));
12 int low = hexValue(str.charAt(i + 1));
13 bytes[index++] = (byte) ((high << 4) + low);
19 public static int hexValue(char c) {
20 return c >= 'a' ? c - 87 : c - 48;