MD5 and password store

Just starting out? Need help? Post your questions and find answers here.
karu
Enthusiast
Enthusiast
Posts: 255
Joined: Fri Jan 13, 2006 12:14 am

MD5 and password store

Post by karu »

Hi,

How to store a password in db, in registry, in ini encrypted width md5 width pb 4.60, can anyone give example?

Thanks
Karu
infratec
Always Here
Always Here
Posts: 7625
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: MD5 and password store

Post by infratec »

Hi karu,

it is not posible to store a password with md5.
You can only store a fingerprint, which means you have always to compare 2 fingerprints and not the password directly.
You should be not able to reconstruct the original password out of the MD5Fingerprint.

Code: Select all

#PrefFile = "c:\tmp\test.pref"

Password$ = "TopSecret"
MD5Password$ = MD5Fingerprint(@Password$, Len(Password$))

OpenPreferences(#PrefFile)
WritePreferenceString("Password", MD5Password$)
ClosePreferences()

Password$ = "Test"
;Password$ = "TopSecret"
MD5Password$ = MD5Fingerprint(@Password$, Len(Password$))
OpenPreferences(#PrefFile)
MD5Pref$ = ReadPreferenceString("Password", "")
If MD5Pref$= MD5Password$
  Debug "Password Ok"
Else
  Debug "Password failed"
EndIf
ClosePreferences()
First it fails.
If you change the comments it is Ok.

Bernd
karu
Enthusiast
Enthusiast
Posts: 255
Joined: Fri Jan 13, 2006 12:14 am

Re: MD5 and password store

Post by karu »

Thanks, this your solution is same what i used before, but with this solution is problem. I have big application, where in different computers, users save other users passwords and md5 fingerprint in different computers is NOT always same, why i don't know, that's why I asked. And if fingerprint is not always the same, how i compare it?

Istead md5, today i use this solution, but i want still use md5:

Code: Select all

  *Buffer = AllocateMemory(500)
  If *Buffer
    PokeS(*Buffer, "password")
    pasword = SHA1Fingerprint(*Buffer, MemorySize(*Buffer))
    FreeMemory(*Buffer)
  EndIf
User avatar
skywalk
Addict
Addict
Posts: 4223
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: MD5 and password store

Post by skywalk »

Why do you want to use MD5? SHA1 is more secure and preferred by many. Though, I read many are using blowfish (bcrypt) since it is better at preventing hacks due to much slower algorithm.

Depending on your goals:
Store Passwords as a HASH(SHA1 or blowfish). Unable to recover original password.
Store Passwords encrypted with AES. Original password can be recovered if keys are shared.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
bhatkins2000
New User
New User
Posts: 9
Joined: Fri Apr 28, 2006 4:20 pm
Location: Missouri

Re: BCrypt

Post by bhatkins2000 »

Has anyone had success using the Bcrypt.dll to encrypt and validate passwords?

Looking for some example code if anyone has.

Thanks for any help.
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: MD5 and password store

Post by Keya »

skywalk wrote:Why do you want to use MD5? SHA1 is more secure and preferred by many.
Why do you want to use SHA1? SHA2 is more... wait. SHA3 was accepted 2015, and Fred's already added PB support :) :)
walbus
Addict
Addict
Posts: 929
Joined: Sat Mar 02, 2013 9:17 am

Re: MD5 and password store

Post by walbus »

@Keya - Think simple
MD5 is ok for this :shock:

Code: Select all

EnableExplicit
UseMD5Fingerprint()

#salt$="86349c23q03457t5&(%)=/?=/()/%$%§?(/§"
Define password$="Your Password"
Define resulted_string$=password$+#salt$
Define hash$=Fingerprint(@resulted_string$, StringByteLength(resulted_string$), #PB_Cipher_MD5)
Debug hash$
@Infratec - This is not OK, this works wrong with unicode
MD5Password$ = MD5Fingerprint(@Password$, Len(Password$))
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: MD5 and password store

Post by Keya »

walbus wrote:@Keya - Think simple
MD5 is ok for this :shock:
Ok i'll think simple: simply change "UseMD5Fingerprint()" to "UseSHA3Fingerprint()", and simply change "#PB_Cipher_MD5" to "#PB_Cipher_SHA3" ... :)
walbus
Addict
Addict
Posts: 929
Joined: Sat Mar 02, 2013 9:17 am

Re: MD5 and password store

Post by walbus »

@Keya - Think simple
The guy use a older PB version without SHA3 :wink:
And it looks, he will not use a newer...
The change for found here a collision with MD5, you can forget
Also you can not use tables for bruting the password
Try it, and post the collision, i think it´s not so simple and how you want this do, you have the salt not ?
Last edited by walbus on Sun Sep 25, 2016 10:37 am, edited 1 time in total.
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: MD5 and password store

Post by Keya »

I dont know enough about them to say whats involved in "breaking MD5" as im not even a mathematician let alone a crypto person so i won't debate how easy or hard it is, but all i know is that using it is like saying F U to your customers security/privacy, so in that sense to me it seems it's truly broken :)
btw if he has a PB older than SHA3 itll probably still have SHA2
Last edited by Keya on Sun Sep 25, 2016 10:45 am, edited 1 time in total.
walbus
Addict
Addict
Posts: 929
Joined: Sat Mar 02, 2013 9:17 am

Re: MD5 and password store

Post by walbus »

Looking for what you want MD5 !
I think not the guy want encrypt 1e6 or more passwords
Also, a password is only a little string
To time still MD5 is the mostly used hash for passwords around the world, i think...
Last edited by walbus on Sun Sep 25, 2016 10:48 am, edited 1 time in total.
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: MD5 and password store

Post by Keya »

yeah but come on, if it's still the most common (i dont know) that's not because it's recommended as best ... :) people just hate updating their systems lol, "if its not broken dont fix it"... (but it kinda is!)
walbus
Addict
Addict
Posts: 929
Joined: Sat Mar 02, 2013 9:17 am

Re: MD5 and password store

Post by walbus »

@Keya
Older PB has not SHA2, only MD5 and SHA1
And the reason he will not use a newer can are different
All hashes have collisions, MD5 here is not a problem
Looking, the complexity from MD5 is 16Bytes, this is more as a lot for a little password with salt, also without salt
Think simple, you must not have a tank for protect you from rain :shock:
Thorium
Addict
Addict
Posts: 1305
Joined: Sat Aug 15, 2009 6:59 pm

Re: MD5 and password store

Post by Thorium »

MD5 is broken. Everyone should only use SHA-3.
Just read up on articals about password hashing. The only reason MD5 is still used a lot is because people are to lazy to update there code.

To resolve a plain MD5 you can just put it in google. Many common passwords can just be retrieved like that.

Watch this for some basic info about password hashing: https://www.youtube.com/watch?v=b4b8ktEV4Bg
Cracking MD5's: https://www.youtube.com/watch?v=7U-RbOKanYs
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: MD5 and password store

Post by Dude »

Thorium wrote:MD5 is broken
For passwords, yes. For generic data integrity checking, not really.

Anyway, MD5 was once considered secure and state-of-the-art... just like people are saying now for SHA3. But in a year or two, SHA3 will also be broken and the Next Big Thing will be recommended.

It's a never-ending cycle.
Post Reply