]> WPIA git - gigi.git/blob - tests/com/lambdaworks/crypto/test/CryptoTestUtil.java
Merge "Update notes about password security"
[gigi.git] / tests / com / lambdaworks / crypto / test / CryptoTestUtil.java
1 // Copyright (C) 2011 - Will Glozer. All rights reserved.
2
3 package com.lambdaworks.crypto.test;
4
5 public class CryptoTestUtil {
6
7     public static byte[] decode(String str) {
8         byte[] bytes = new byte[str.length() / 2];
9         int index = 0;
10
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);
15         }
16
17         return bytes;
18     }
19
20     public static int hexValue(char c) {
21         return c >= 'a' ? c - 87 : c - 48;
22     }
23 }