# sha-1

Olaf Dokter (olaf.dokter@nk.anzeiger.net)
Sat, 26 Dec 1998 19:14:49 +0100

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: creditman5@usa.net: "CREDIT CARD PROCESSING"
- Previous message: Rick Eriksen: "ADV: Discover the fortune that lies hidden in your website!"

This is a multi-part message in MIME format.

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

- Next message: creditman5@usa.net: "CREDIT CARD PROCESSING"
- Previous message: Rick Eriksen: "ADV: Discover the fortune that lies hidden in your website!"