Hack Forums
[.NET] (True = True) isn't equals ! - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] (True = True) isn't equals ! (/showthread.php?tid=3946539)

Pages: Pages 1 2


(True = True) isn't equals ! - Brokeos - Dec 23, 2013

Hello, I have a big problem!

I get back a file ini, everything goes well, it corresponds to what I want.
Then, I read the value "pass" of the ini file.
And, when I compare the value return of my Sha512 with the value "pass" of the ini file, He says that it is different! but nevertheless they are similar!

French :

Bonjours, j'ai un gros problème

J'ai un fichier ini que je lis, tout ce passe bien.
Je récupére la valeur "pass" du fichier ini.
Et, quand je compare la valeur retourner de ma fonction Sha512 avec la valeur "pass" du fichier ini, il me dit que c'est différent pourtant ils sont pareils ! (j'ai fait le test avec des msgbox !)


* - VPN - Dec 23, 2013

Msgbox the both values and check where is the problem.


* - Brokeos - Dec 23, 2013

I already checked x)

[image deleted !]


* - Temploit - Dec 23, 2013

Put .Trim at the end of both values. It might be a space which makes the difference.


* - Brokeos - Dec 23, 2013

No, I tested everything !
If you want, I load the project and I'll send?


* - 0xDEAD10CC - Dec 23, 2013

If you tested everything and it isn't working then you are doing something wrong; you didn't test everything. Post the relevant code, and show what the values are that are being compared. They are different.

Breakpoint and see the hash to hash comparison.


* - Brokeos - Dec 23, 2013

I found, even if it is not very clean, I separate the "pass" profile file


* - Ajumma - Dec 23, 2013

Please show your code. Can't really help much without it.
Did you hash the input and check it with the value in the ini file?
Is the value in the ini file a SHA512 hash also?


* - zyvox - Dec 23, 2013

Try adding a msgbox to display both the values so you can see the difference for yourself?


* - Pseudocode - Dec 23, 2013

Trim the end, then, if it is a string, try using String.Equals()


* - 0xDEAD10CC - Dec 23, 2013

(Dec 23, 2013 03:20 PM)Pseudocode Wrote:  Trim the end, then, if it is a string, try using String.Equals()

Why would it not be a string if you can call a Trim function on the object? Aside from the fact that it is a string as mentioned.

However, this is literally a 5 second proof that could be configured to see that the values are probably different, and a 1-5 minute fix at most depending on how he's got everything implemented, and OP doesn't take our word for it. Let 'em have at it if he truly things those strings are the same IMO, lol.

@OP:
(Dec 23, 2013 09:51 AM)Brokeos Wrote:  I found, even if it is not very clean, I separate the "pass" profile file

Btw, I replied. How does this have anything to do with the suggestions I posted? And how does it help us help you when it isn't even relevant to the question this thread's creation was based off of? 🤨 Separation of files has nothing to do with whether or not 2 strings are evaluating as equal or not.

1. Did you try breakpointing?
2. Did you post any code? (a bit rhetorical)

I haven't seen anything, and you expect to get help? ❓ We might as well just be running around like drunken blindfolded idiots with guns trying to shoot a target.


* - Brokeos - Dec 24, 2013

Code
Private Sub btn_login_Click(sender As Object, e As EventArgs) Handles btn_login.Click
    If txt_user.Text.Equals("") Or txt_pass.Text.Equals("") Then
        MsgBox("Wrong data !", MsgBoxStyle.Critical)
    Else
        IO.File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\CloudUp\settings.ini", DownloadSource(server & "users/" & txt_user.Text & "/account.info")
        If ReadIni("Profil","pass",Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\CloudUp\settings.ini") = Sha512(txt_pass.Text) Then
            WritePrivateProfileString("Login", "user", txt_user.Text, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\CloudUp\settings.ini")
            WritePrivateProfileString("Login", "pass", txt_pass.Text, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\CloudUp\settings.ini")
            MsgBox("Hello " & txt_user.Text & " !", MsgBoxStyle.Information)
            user = txt_user.Text
            Cloud.Show()
            Me.Close()
        Else
    MsgBox("Wrong username or password !", MsgBoxStyle.Critical)
        End If
        IO.File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\CloudUp\~temp.ini")
    End If
End Sub

Sha512 Function = Original sha256 x2 (Sha256(Sha256(MyText)))
ReadIni Function =  
Public Function ReadIni(ByVal cRubrique As String, ByVal cKey As String, ByVal cFileName As String) As String
  Dim cRepertoire As String = Space(255)
  Get_Private_Profile_String(cRubrique, cKey, "", cRepertoire, cFileName)
  Return Trim(cRepertoire)
End Function

DownloadSource Function = Net.WebClient.DownloadString(url)



* - Temploit - Dec 24, 2013

Dim cRepertoire As String = Space(255)

Check the lenght of both string (.Lenght())
I think one has 255 while the other way less.


* - Brokeos - Dec 24, 2013

No, the function works well ;)
When I ask the pass value, she return good value ;)


* - Temploit - Dec 24, 2013

(Dec 24, 2013 04:15 AM)Brokeos Wrote:  No, the function works well ;)
When I ask the pass value, she return good value ;)
How do you know it's a good value?
Just because they look the same doesn't mean they are the same (spaces)