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