Dec 11, 2019 Replies: 10 Ola Was recently requested to look at this by a friend, for encryption 1. Download this repo here to get the md5 javascript resource https://github.com/blueimp/JavaScript-MD5 2. In your BANano project, add the javascript file Code: Copy BANano.Header.AddJavascriptFile("md5.min.js") 3. Add this code to your code module in your project Code: Copy 'get md5hash Sub Md5Hash(value As String, key As String, raw As Boolean) As String Dim res As Object = BANano.RunJavascriptMethod("md5", Array(value, key, raw)) Return res End Sub 4. Usage Code: Copy Log(Md5Hash("TheMash", Null, False)) Log(Md5Hash("TheMash", "AneleMbanga", False)) Log(Md5Hash("TheMash", Null, True)) Log(Md5Hash("TheMash", "AneleMbanga", True)) 5. Output. One can use this to store hashed passwords in the database, checksums to verify data integrity, detect unintentional data corruption depending on the complexity ones need. Enjoy. Last edited: Nov 16, 2021 Click to expand...
Ola Was recently requested to look at this by a friend, for encryption 1. Download this repo here to get the md5 javascript resource https://github.com/blueimp/JavaScript-MD5 2. In your BANano project, add the javascript file Code: Copy BANano.Header.AddJavascriptFile("md5.min.js") 3. Add this code to your code module in your project Code: Copy 'get md5hash Sub Md5Hash(value As String, key As String, raw As Boolean) As String Dim res As Object = BANano.RunJavascriptMethod("md5", Array(value, key, raw)) Return res End Sub 4. Usage Code: Copy Log(Md5Hash("TheMash", Null, False)) Log(Md5Hash("TheMash", "AneleMbanga", False)) Log(Md5Hash("TheMash", Null, True)) Log(Md5Hash("TheMash", "AneleMbanga", True)) 5. Output. One can use this to store hashed passwords in the database, checksums to verify data integrity, detect unintentional data corruption depending on the complexity ones need. Enjoy.
alwaysbusy Expert Licensed User Longtime User Dec 11, 2019 #2 I guess this is transpiled by BANano. Isn't your password exposed then?
Mashiane Expert Licensed User Longtime User Dec 11, 2019 #3 alwaysbusy said: I guess this is transpiled by BANano. Isn't your password exposed then? Click to expand... Because hashing is one way, one can implement this by... 1. On a user registration screen, you ask for the password, you don't save the actual password on the db but then hash it and save the hashed password on the db using this option for example. Code: Copy Dim save2db As string = Md5Hash(<UserPassword>, Null, False)) 2. On the login screen, you ask the password of the user, this is then hashed using the same hash method you did for the registration. 3. You then compare the hashed value in the db and the one the user is using to login. If the hash values match, then a successful login is ensured, if not the passwords do not match and no login is done. In both cases, the real password never actually gets revealed. In this scenario, you have a system that DOES NOT KNOW peoples passwords like MegaSync for example. Last edited: Dec 11, 2019
alwaysbusy said: I guess this is transpiled by BANano. Isn't your password exposed then? Click to expand... Because hashing is one way, one can implement this by... 1. On a user registration screen, you ask for the password, you don't save the actual password on the db but then hash it and save the hashed password on the db using this option for example. Code: Copy Dim save2db As string = Md5Hash(<UserPassword>, Null, False)) 2. On the login screen, you ask the password of the user, this is then hashed using the same hash method you did for the registration. 3. You then compare the hashed value in the db and the one the user is using to login. If the hash values match, then a successful login is ensured, if not the passwords do not match and no login is done. In both cases, the real password never actually gets revealed. In this scenario, you have a system that DOES NOT KNOW peoples passwords like MegaSync for example.
Mashiane Expert Licensed User Longtime User Dec 11, 2019 #4 An interesting article about MD5 and passwords. https://www.johndcook.com/blog/2019/01/24/reversing-an-md5-hash/ It seems the stronger the password is and hash method used e.g. with a key, the more difficult it is to reverse/decrypt.
An interesting article about MD5 and passwords. https://www.johndcook.com/blog/2019/01/24/reversing-an-md5-hash/ It seems the stronger the password is and hash method used e.g. with a key, the more difficult it is to reverse/decrypt.
alwaysbusy Expert Licensed User Longtime User Dec 11, 2019 #5 And the DB is on the server side of course because MD5 is vulnerable to brute force attacks and as it is a fast hash, one can relatively quick find a plain text match that generates a desired hash, especially with passwords. It is always better to do all encryption on the server side using something strong like bcrypt and you can protect yourself against brute force attacks e.g. with a DoS filter.
And the DB is on the server side of course because MD5 is vulnerable to brute force attacks and as it is a fast hash, one can relatively quick find a plain text match that generates a desired hash, especially with passwords. It is always better to do all encryption on the server side using something strong like bcrypt and you can protect yourself against brute force attacks e.g. with a DoS filter.
Mashiane Expert Licensed User Longtime User Dec 11, 2019 #6 Well said, @alwaysbusy and people realizing this, have created things like HashToolkit, https://hashtoolkit.com to decrypt these hashes back to their original values. Thanks for the feedback. Last edited: Dec 11, 2019
Well said, @alwaysbusy and people realizing this, have created things like HashToolkit, https://hashtoolkit.com to decrypt these hashes back to their original values. Thanks for the feedback.
J joulongleu Active Member Licensed User Longtime User Dec 14, 2019 #7 Hi: Mashiane,After trying for a few days, it finally works,Thank You very much.
Mashiane Expert Licensed User Longtime User Dec 15, 2019 #8 More on this topic here, https://www.b4x.com/android/forum/t...-types-4-algorithm-plus-1.112222/#post-699732
More on this topic here, https://www.b4x.com/android/forum/t...-types-4-algorithm-plus-1.112222/#post-699732
ilan Expert Licensed User Longtime User Apr 12, 2021 #9 Mashiane said: Well said, @alwaysbusy and people realizing this, have created things like HashToolkit, https://hashtoolkit.com to decrypt these hashes back to their original values. Thanks for the feedback. Click to expand... how is that possible? it should be very hard for a desktop pc (too many combinations) to decrypted HASH back to string?!?! i know methods, where you have big HASH tables that contain common passwords and compare them but making the decryption in real-time, should be hard, right?
Mashiane said: Well said, @alwaysbusy and people realizing this, have created things like HashToolkit, https://hashtoolkit.com to decrypt these hashes back to their original values. Thanks for the feedback. Click to expand... how is that possible? it should be very hard for a desktop pc (too many combinations) to decrypted HASH back to string?!?! i know methods, where you have big HASH tables that contain common passwords and compare them but making the decryption in real-time, should be hard, right?
Mashiane Expert Licensed User Longtime User Apr 12, 2021 #10 @ilan , yes it should be impossible actually. On their site, they claim have been able to decrypt the hashes.
@ilan , yes it should be impossible actually. On their site, they claim have been able to decrypt the hashes.
ilan Expert Licensed User Longtime User Apr 13, 2021 #11 Mashiane said: @ilan , yes it should be impossible actually. On their site, they claim have been able to decrypt the hashes. Click to expand... ok i understand what they are doing. they are not decrypt hashes what they do they have a big table wish hashes and search in this table. if the hash exists they return the string as i wrote in the post above: ilan said: i know methods, where you have big HASH tables that contain common passwords and compare them Click to expand... as you can see they are searching IN 20.460.908.791DECRYPTED HASHES. this is a known method where hackers are using tables of common words like from a dictionary book or phone book and run there hashes and compare with the hashes they stole from db's and like this return the password. you know that a computer can calculate about 20 billion hashes/second so thats a lot!! that means that in less then 1 second you can create all phone numbers from a public phone book and all words in a dictionary + many many words combination. this is why we should use salting. salting = create a random string and include it in your db. then hash the user password + salting string and save it as the hash value in your db. like this you can avoid different users have the same Hash value. to get a higher security level use Salt Rounds with bcrypt as @alwaysbusy already recommended above. very interesting topic
Mashiane said: @ilan , yes it should be impossible actually. On their site, they claim have been able to decrypt the hashes. Click to expand... ok i understand what they are doing. they are not decrypt hashes what they do they have a big table wish hashes and search in this table. if the hash exists they return the string as i wrote in the post above: ilan said: i know methods, where you have big HASH tables that contain common passwords and compare them Click to expand... as you can see they are searching IN 20.460.908.791DECRYPTED HASHES. this is a known method where hackers are using tables of common words like from a dictionary book or phone book and run there hashes and compare with the hashes they stole from db's and like this return the password. you know that a computer can calculate about 20 billion hashes/second so thats a lot!! that means that in less then 1 second you can create all phone numbers from a public phone book and all words in a dictionary + many many words combination. this is why we should use salting. salting = create a random string and include it in your db. then hash the user password + salting string and save it as the hash value in your db. like this you can avoid different users have the same Hash value. to get a higher security level use Salt Rounds with bcrypt as @alwaysbusy already recommended above. very interesting topic