MD5 for text [Resolved]

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5509
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

MD5 for text [Resolved]

Post 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
Last edited by Kwai chang caine on Thu Nov 13, 2025 7:33 pm, edited 3 times in total.
ImageThe happiness is a road...
Not a destination
infratec
Always Here
Always Here
Posts: 7676
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: MD5 for text

Post 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:
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5509
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: MD5 for text

Post 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
ImageThe happiness is a road...
Not a destination
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5509
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: MD5 for text [Resolved]

Post 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$)
ImageThe happiness is a road...
Not a destination
Bitblazer
Enthusiast
Enthusiast
Posts: 769
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: MD5 for text

Post by Bitblazer »

Maybe CRC32Fingerprint is good enough for you.
normeus
Enthusiast
Enthusiast
Posts: 480
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: MD5 for text

Post 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.
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
BarryG
Addict
Addict
Posts: 4239
Joined: Thu Apr 18, 2019 8:17 am

Re: MD5 for text [Resolved]

Post 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.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5509
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: MD5 for text

Post 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)
ImageThe happiness is a road...
Not a destination
infratec
Always Here
Always Here
Posts: 7676
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: MD5 for text [Resolved]

Post 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
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5509
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: MD5 for text [Resolved]

Post 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 ?
ImageThe happiness is a road...
Not a destination
User avatar
kenmo
Addict
Addict
Posts: 2062
Joined: Tue Dec 23, 2003 3:54 am

Re: MD5 for text [Resolved]

Post 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.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5509
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: MD5 for text [Resolved]

Post by Kwai chang caine »

Yes, you're right, I hadn't really made the distinction in my head. :wink: :oops:
ImageThe happiness is a road...
Not a destination
Post Reply