------=_NextPart_000_0004_01BE3104.01F646E0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
i need to use the message-digest with the sha-1 algorithm.
i used it in this way:
import java.math.*;
import java.security.*;
// -5666c1c9b8f97e9545c1da8e87af3d93632f2763
// -7b67c1bbe3c42d914551b55e06aed61a1ab98f0f
public class testsha
{
public static void main(String args[])
{
=20
String exA =3D "011000010110001001100011";
String exB =3D =
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
=20
String resA =3D "A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D";=20
String resB =3D "84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1";
=20
BigInteger bi1,bi2;
=20
MessageDigest md;
=20
byte target[];
=20
try
{
md =3D MessageDigest.getInstance("SHA-1");
=20
bi1=3Dnew BigInteger(exA,2);
target =3D bi1.toByteArray();
md.reset();
md.update(target);
bi1=3Dnew BigInteger(md.digest());
=20
target =3D exB.getBytes();
md.reset();
md.update(target);
bi2=3Dnew BigInteger(md.digest());
=20
System.out.println("result a: "+bi1.toString(16));
System.out.println("result b: "+bi2.toString(16));
=20
System.out.println("FIPS 180-1 result a: "+resA);
System.out.println("FIPS 180-2 result b: "+resB);
=20
System.exit(0);
} catch (Exception e) { System.out.println(e); System.exit(0); }
}
}
The two outputs have to be equal to the examples in the NIST-FIPS 180-1. =
but that is not so. did i do something wrong in the way how i used the =
message-digest ?
thank you.
yours sincerely
olaf dokter=20
------=_NextPart_000_0004_01BE3104.01F646E0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">