Old CRC32Fingerprint() Versus Fingerprint()

Just starting out? Need help? Post your questions and find answers here.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Old CRC32Fingerprint() Versus Fingerprint()

Post by Karbon »

So I have some legacy code where some checksums were created using this code ( I think in PB 4.4).

(New Code)

Code: Select all

Str(Val("$"+Fingerprint(@temp_kb7,StringByteLength(temp_kb7,#PB_Ascii),#PB_Cipher_CRC32)))
(Old Code)

Code: Select all

Str(CRC32Fingerprint(@temp_kb7,StringByteLength(temp_kb7)))
Given the same data, the two checksums are different. I need to figure out how to make the first example generate the exact same checksum as the second (given the same data of course).

I don't have access to the manual from PB 4.40 right now to look and see if it is documented differently. Can anyone help me out?
Last edited by Karbon on Wed Jan 24, 2018 10:27 pm, edited 1 time in total.
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
User avatar
JHPJHP
Addict
Addict
Posts: 2250
Joined: Sat Oct 09, 2010 3:47 am

Re: Old CRC32Fingerprint() Versus Fingerprint()

Post by JHPJHP »

Hi Karbon,

Try the following:

Code: Select all

nLength = StringByteLength(temp_kb7, #PB_Ascii)
*temp_kb7 = AllocateMemory(nLength)
PokeS(*temp_kb7, temp_kb7, nLength, #PB_Ascii)
Fingerprint(*temp_kb7, nLength, #PB_Cipher_CRC32)

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Re: Old CRC32Fingerprint() Versus Fingerprint()

Post by Karbon »

Unfortunately that wasn't it (It's an all-ASCII program and I'm using the LTS version for exactly that reason).

Since the original function returned an integer and that's what was stored, and the new version returns a hex string, I'm actually comparing like this :

Code: Select all

Str(Val("$"+Fingerprint(@temp_kb7,StringByteLength(temp_kb7,#PB_Ascii),#PB_Cipher_CRC32)))
But still a no-go. I must be missing something since if it's a true CRC32 implementation the checksums shouldn't ever be different. I'm going to grab the old version and install it when I get back to the house, I just can't download it here over this crappy 4G connection.
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Re: Old CRC32Fingerprint() Versus Fingerprint()

Post by Karbon »

You're right, I only saw the original post. Same thing, though, you just unrolled it a bit in your last as far as I can tell..

Other than the #PB_ASCII I don't see any difference in your example and mine.. Am I missing something there?
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
User avatar
JHPJHP
Addict
Addict
Posts: 2250
Joined: Sat Oct 09, 2010 3:47 am

Re: Old CRC32Fingerprint() Versus Fingerprint()

Post by JHPJHP »

Hi Karbon,

Are you able to post the original string and the expected checksum?

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: Old CRC32Fingerprint() Versus Fingerprint()

Post by nco2k »

pb doesnt have unsigned longs and Str() expects a quad / Val() returns a quad.

old:

Code: Select all

MyLong.l = CRC32Fingerprint(?MyString, ?MyStringEnd - ?MyString)
Debug Str(MyLong)
Debug Str(CRC32Fingerprint(?MyString, ?MyStringEnd - ?MyString) & $FFFFFFFF)
Debug StrU(CRC32Fingerprint(?MyString, ?MyStringEnd - ?MyString), #PB_Long)
Debug UCase(RSet(Hex(CRC32Fingerprint(?MyString, ?MyStringEnd - ?MyString), #PB_Long), 8, "0"))

DataSection
  MyString:
  Data.a $48, $65, $6C, $6C, $6F
  MyStringEnd:
EndDataSection
new:

Code: Select all

UseCRC32Fingerprint()

MyLong.l = Val("$"+Fingerprint(?MyString, ?MyStringEnd - ?MyString, #PB_Cipher_CRC32))
Debug Str(MyLong)
Debug Str(Val("$"+Fingerprint(?MyString, ?MyStringEnd - ?MyString, #PB_Cipher_CRC32)))
Debug UCase(RSet(Fingerprint(?MyString, ?MyStringEnd - ?MyString, #PB_Cipher_CRC32), 8, "0"))

DataSection
  MyString:
  Data.a $48, $65, $6C, $6C, $6F
  MyStringEnd:
EndDataSection
i still hope that regular Str() gets an optional type like StrU() - http://www.purebasic.fr/english/viewtop ... =3&t=64823

c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Re: Old CRC32Fingerprint() Versus Fingerprint()

Post by Karbon »

So shouldn't these be producing the same string?

New

Code: Select all

Str(Val("$"+Fingerprint(@temp_kb7,StringByteLength(temp_kb7,#PB_Ascii),#PB_Cipher_CRC32)))
Old

Code: Select all

Str(CRC32Fingerprint(@temp_kb7,StringByteLength(temp_kb7)))
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: Old CRC32Fingerprint() Versus Fingerprint()

Post by nco2k »

no, because Val("$"+X) will return the unsigned value of the hex string.

Code: Select all

MyQuad.q = Val("$"+Fingerprint(@temp_kb7,StringByteLength(temp_kb7,#PB_Ascii),#PB_Cipher_CRC32))
Debug Str(MyQuad)
MyLong.l = Val("$"+Fingerprint(@temp_kb7,StringByteLength(temp_kb7,#PB_Ascii),#PB_Cipher_CRC32))
Debug Str(MyLong)
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Re: Old CRC32Fingerprint() Versus Fingerprint()

Post by Karbon »

Well, damn... I thought you were saying your old/new examples above were equivalents.

Do you have any idea what the old CRC32Fingerprint() returned?
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: Old CRC32Fingerprint() Versus Fingerprint()

Post by nco2k »

Karbon wrote:Well, damn... I thought you were saying your old/new examples above were equivalents.
they are. just run them when u get home.
Karbon wrote:Do you have any idea what the old CRC32Fingerprint() returned?
yes, a signed long.

c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Re: Old CRC32Fingerprint() Versus Fingerprint()

Post by Karbon »

Awesome -- thank you!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Post Reply