]> WPIA git - gigi.git/blob - tests/com/lambdaworks/crypto/test/CryptoTestUtil.java
add: import scrypt 1.4.0
[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     public static byte[] decode(String str) {
7         byte[] bytes = new byte[str.length() / 2];
8         int index = 0;
9
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);
14         }
15
16         return bytes;
17     }
18
19     public static int hexValue(char c) {
20         return c >= 'a' ? c - 87 : c - 48;
21     }
22 }