Wrong SHA1 is calculated

[email protected] (Martin Puppe) Mon, 15 May 2017 10:39:07 +0000
Newsgroups perl.win32.vanilla
Message-ID <[email protected]>
--_000_805039a31cbf4106a210bd1b3c533080jamsoftwarecom_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hello,

I am debugging a problem with SHA1 checksums. I have found the following ha=
ndy one-liner on Stack Overflow [^1], which serves well as a minimal exampl=
e:

```
perl -MDigest::SHA1=3Dsha1_hex -le "print sha1_hex <>" secure.txt
```

The problem is, that the result is simply not correct. Doing the same on a =
Unix system gives the correct result. And I also get a correct result when =
I generate the SHA1 sum with the 7-zip file manager.

Any ideas what the problem might be?

[^1]: http://stackoverflow.com/a/2812212

Best regards,
Martin Puppe
JAM Software

________________________________



--------------------------------------------------------
JAM Software GmbH
Managing Director: Joachim Marder
Am Wissenschaftspark 26 * 54296 Trier * Germany
Phone: +49 (0)651-145 653 -0 * Fax: +49 (0)651-145 653 -29
Commercial register number HRB 4920 (AG Wittlich) http://www.jam-software.c=
om

________________________________



----------------------------------------------------
JAM Software GmbH
Gesch?ftsf?hrer: Joachim Marder
Am Wissenschaftspark 26 * 54296 Trier * Germany
Tel: 0651-145 653 -0 * Fax: 0651-145 653 -29
Handelsregister Nr. HRB 4920 (AG Wittlich) http://www.jam-software.de

--_000_805039a31cbf4106a210bd1b3c533080jamsoftwarecom_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;
	mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:#0563C1;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:#954F72;
	text-decoration:underline;}
span.E-MailFormatvorlage17
	{mso-style-type:personal-compose;
	font-family:"Calibri",sans-serif;
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri",sans-serif;
	mso-fareast-language:EN-US;}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"DE" link=3D"#0563C1" vlink=3D"#954F72">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span lang=3D"EN-US">Hello,<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US">I am debugging a problem with S=
HA1 checksums. I have found the following handy one-liner on Stack Overflow=
 [^1], which serves well as a minimal example:<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US">```<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US">perl -MDigest::SHA1=3Dsha1_hex =
-le &quot;print sha1_hex &lt;&gt;&quot; secure.txt<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US">```<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US">The problem is, that the result=
 is simply not correct. Doing the same on a Unix system gives the correct r=
esult. And I also get a correct result when I generate the SHA1 sum with th=
e 7-zip file manager.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US">Any ideas what the problem migh=
t be?<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US">[^1]: <a href=3D"http://stackov=
erflow.com/a/2812212">
http://stackoverflow.com/a/2812212</a><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US">Best regards,<o:p></o:p></span>=
</p>
<p class=3D"MsoNormal"><span lang=3D"EN-US">Martin Puppe<o:p></o:p></span><=
/p>
<p class=3D"MsoNormal"><span lang=3D"EN-US">JAM Software<o:p></o:p></span><=
/p>
</div>
<br>
<hr>
<font face=3D"Arial" color=3D"Gray" size=3D"2"><br>
<br>
<br>
--------------------------------------------------------<br>
JAM Software GmbH<br>
Managing Director: Joachim Marder<br>
Am Wissenschaftspark 26 * 54296 Trier * Germany<br>
Phone: &#43;49 (0)651-145 653 -0 * Fax: &#43;49 (0)651-145 653 -29<br>
Commercial register number HRB 4920 (AG Wittlich) http://www.jam-software.c=
om<br>
</font><br>
<hr>
<font face=3D"Arial" color=3D"Gray" size=3D"2"><br>
<br>
<br>
----------------------------------------------------<br>
JAM Software GmbH<br>
Gesch&auml;ftsf&uuml;hrer: Joachim Marder<br>
Am Wissenschaftspark 26 * 54296 Trier * Germany<br>
Tel: 0651-145 653 -0 * Fax: 0651-145 653 -29<br>
Handelsregister Nr. HRB 4920 (AG Wittlich) http://www.jam-software.de<br>
</font>
</body>
</html>

--_000_805039a31cbf4106a210bd1b3c533080jamsoftwarecom_--