* config/rs6000/rs6000.c (rs6000_deligitimze_address): Do not
[official-gcc.git] / libjava / testsuite / libjava.lang / shatest.java
blob4cc6d4f41828d990516841bdb6b13bd27a896f6a
1 import java.security.*;
3 class shatest {
5 // gnu-crypto/source/gnu/testlet/gnu/crypto/hash/TestOfSha160.java
7 public static void main(String[] argv) {
8 MessageDigest md=null;
9 try {
10 md = MessageDigest.getInstance("SHA-1");
11 } catch (Exception e) {
12 e.printStackTrace();
14 md.update("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq".getBytes(), 0, 56);
15 String exp = "84983E441C3BD26EBAAE4AA1F95129E5E54670F1";
16 String result = toString(md.digest());
17 System.out.println(exp);
18 System.out.println(result);
19 if (!exp.equals(result))
20 System.out.println("NOT EQUAL!");
24 public static String toString(byte[] ba) {
25 return toString(ba, 0, ba.length);
27 public static final String toString(byte[] ba, int offset, int length) {
28 char[] buf = new char[length * 2];
29 for (int i = 0, j = 0, k; i < length; ) {
30 k = ba[offset + i++];
31 buf[j++] = HEX_DIGITS[(k >>> 4) & 0x0F];
32 buf[j++] = HEX_DIGITS[ k & 0x0F];
34 return new String(buf);
37 private static final char[] HEX_DIGITS = "0123456789ABCDEF".toCharArray();