Page 1 of 1

MD5 for text [Resolved]

Posted: Sun Nov 09, 2025 8:06 pm
by Kwai chang caine
Hello at all :D

It's surely again a "Dyingoflaughter" :lol: question for you, but i dare when even :oops:

Exist it ...a style of MD5 for a text, that is... a way for crypting a text in another text, but the most shorter possible and also unique a style of "KEY" what, for be sure this two text are the same :idea:
Like this i can compare two texts of (for exampler) 20 characters with a (for exampler) key of 4 to 6 characters or less if possible :mrgreen:
I hope i have good explained, what cow pat idea i have again, in the bidet that serves as my brain :oops:

Have a good day

Re: MD5 for text

Posted: Sun Nov 09, 2025 8:40 pm
by infratec
In former days a password was stored as MD5 hash, not the real password.
Today a Sha256 or 512 hash is stored.
So your idea is not new :wink:

Re: MD5 for text

Posted: Sun Nov 09, 2025 9:32 pm
by Kwai chang caine
Hello INFRATEC glad to read you :D

It's not an idea (A good idea from KCC... that would be too good to be true :mrgreen: ) ...it's a lack of knowledge, like usually :(

What idiot i am :oops:
Since the begining..i use only FileFingerprint() for testing same files, so i believe it's the only one function
And when i read your answer... i guess "Perhaps there are another function that "FileFingerprint()" in the cipher library ?" :?:
I open the help... and see "StringFingerprint()" :oops:

Thanks a lot for your precious help, i test that immediately :wink:
I not need a strong encryption, but the shorter KEY possible, it's for create a "reference"
Have a very good day

Re: MD5 for text [Resolved]

Posted: Sun Nov 09, 2025 10:05 pm
by Kwai chang caine
Unfortunately the MD5 is really longer than the original text :cry:
That not works for what i need to do :|

For the moment..i have create a cow pat code..
But it's not perfect (KCC trademark :mrgreen:), i have the same REF for two different titles :cry:
Debugger wrote:DIBAEL4
DIBAEL4

Code: Select all

Procedure.s CreateUniqueShortKey(NomElement.s)

 NormElement$ = RemoveString(NomElement, "'")
 Interprete$ = Trim(StringField(NormElement$, 1, "("))
 
 If Interprete$ <> ""
  
  Interprete$ = ReplaceString(Interprete$, "  ", " ")
  MaxEspaces = CountString(Interprete$, " ") + 1
  Ref$ = ""
  
  For i = 1 To MaxEspaces
   Ref$ + UCase(Left(StringField(Interprete$, i, " "), 2))
  Next
  
 EndIf
 
 Titre$ = Trim(StringField(StringField(NormElement$, 2, "("), 1, ")"))
 Titre$ = Trim(StringField(Titre$, 1, "'"))
 
 If Titre$ <> ""
  
  Titre$ = ReplaceString(Titre$, "  ", " ")
  MaxEspaces = CountString(Titre$, " ") + 1
       
  For i = 1 To MaxEspaces
   Ref$ + UCase(Left(StringField(Titre$, i, " "), 2))
  Next
  
  Ref$ + Trim(Str(Len(Titre$)))
  
 EndIf
 
 ProcedureReturn Ref$

EndProcedure

Title1$ = "Didier Barbelivien (Elle) Slow.mp3"
Title2$ = "Didier Barbelivien (Elsa) Slow.mp3"

Debug CreateUniqueShortKey(Title1$)
Debug CreateUniqueShortKey(Title2$)

Re: MD5 for text

Posted: Mon Nov 10, 2025 11:33 am
by Bitblazer
Maybe CRC32Fingerprint is good enough for you.

Re: MD5 for text

Posted: Mon Nov 10, 2025 4:54 pm
by normeus
The help example for PB 6.21 (x64) is different from the one on the website, the one on the web is for older versions of PB:

Code: Select all

UseCRC32Fingerprint()
Debug StringFingerprint("Didier Barbelivien (Elsa) Slow.mp3", #PB_Cipher_CRC32) ; KCC's text
Debug StringFingerprint("Didier Barbelivien (Elle) Slow.mp3", #PB_Cipher_CRC32) ; KCC's text
Norm.

Re: MD5 for text [Resolved]

Posted: Tue Nov 11, 2025 12:37 am
by BarryG
Kwai chang caine wrote: Sun Nov 09, 2025 10:05 pmUnfortunately the MD5 is really longer than the original text
Maybe use Left() on it to crop it? Should still be a unique result if not used for private or critical situations.

Re: MD5 for text

Posted: Thu Nov 13, 2025 7:30 pm
by Kwai chang caine
You have right the CRC32 is really shorter than MD5, that's incredible, i can use it, because it divided the len of text by more than 4 :shock:
I would have thought that a newer and more powerful encryption would necessarily take longer, but not at all

On the other hand, it's funny a CRC32 of CRC32 have the same lenght, i don't understand why :shock:

Code: Select all

UseMD5Fingerprint()
UseCRC32Fingerprint()

Text1$ = "Didier Barbelivien (Elsa) Slow.mp3"
Text2$ = "Didier Barbelivien (Elle) Slow.mp3"

Debug "Len text 1 = " + Len(Text1$)
Debug "Len text 2 = " + Len(Text2$)
Debug ""

MD5_1$ = StringFingerprint(Text1$,  #PB_Cipher_MD5) ; KCC's text
MD5_2$ = StringFingerprint(Text2$,  #PB_Cipher_MD5) ; KCC's text

Debug "Len MD5 1 = " + Len(MD5_1$)
Debug "Len MD5 2 = " + Len(MD5_2$)
Debug ""

CRC32_1$ = StringFingerprint(Text1$,  #PB_Cipher_CRC32) ; KCC's text
CRC32_2$ = StringFingerprint(Text2$,  #PB_Cipher_CRC32) ; KCC's text

Debug "Len CRC32 1 = " + Len(CRC32_1$)
Debug "Len CRC32 2 = " + Len(CRC32_2$)
Debug ""

CRC32_1x2$ = StringFingerprint(CRC32_1$,  #PB_Cipher_CRC32) ; KCC's text
CRC32_2x2$ = StringFingerprint(CRC32_2$,  #PB_Cipher_CRC32) ; KCC's text

Debug "Len CRC32_1 x 2 = " + Len(CRC32_1x2$)
Debug "Len CRC32_2 x 2 = " + Len(CRC32_2x2$)
Thanks a lot at you three and have a very good day 8)

Re: MD5 for text [Resolved]

Posted: Thu Nov 13, 2025 10:06 pm
by infratec
CRC32 means that the result is always 32 bit wide.
If you let run it above 1 byte or 1 tera byte the result is always 4 byte long.

There is also CRC16, CRC8, CRC7 and CRC1 available. :mrgreen:

https://en.wikipedia.org/wiki/Cyclic_redundancy_check

Code example:

https://de.wikipedia.org/wiki/Zyklische ... zw._Delphi

ModBus CRC in PB:
viewtopic.php?p=625650#p625650

Re: MD5 for text [Resolved]

Posted: Fri Nov 14, 2025 7:18 pm
by Kwai chang caine
Thanks a lot for your explanation 8)

But i believe you forgot you talk to KCC :mrgreen:
KCC understand each word, but it's all the words together who do the sentence that KCC not really understood :oops:
Master wrote:There is also CRC16, CRC8, CRC7 and CRC1 available
Apparently Fred have not coded the CRC under 32 :cry: probably because it's pointless to have weaker encryption than the one everyone else uses.
Believe you a CR1 (for example) can return a shorter result than the CRC32 ?

Re: MD5 for text [Resolved]

Posted: Fri Nov 14, 2025 8:47 pm
by kenmo
Hello, CRC (and MD5) are not "encryption", meaning they cannot be turned back into the original text. I hope you understand that! Look up the differences between checksum/hash/digest vs. encryption/decryption.

Re: MD5 for text [Resolved]

Posted: Fri Nov 14, 2025 9:04 pm
by Kwai chang caine
Yes, you're right, I hadn't really made the distinction in my head. :wink: :oops: