none
Native library pre-loader is trying to load native SQLite library - Nothing Happen RRS feed

  • Question

  • HI,

    I'm try to create text login project with encrypted passwords. this project was work prefetly before and now it's not working with user login part. but, i can add user it's working same as before. when i try to login this is the final event shows as output. after this nothing happen with login :(

    Screen Shot: 

     

    My Code in Form:

    Dim username As String = TextBox1.Text
            Dim password = Encryption.HashString(TextBox2.Text)
            Dim salt = Encryption.GenarateSalt
            Dim hashedAndSalted = Encryption.HashString(String.Format("{0}{1}", password, salt))
    
            DBManager.Login(TextBox1.Text, TextBox2.Text)

    Code in Class:

     Private ReadOnly CryotiServiceProvider As Security.Cryptography.RNGCryptoServiceProvider
    
        Public Shared Function HashString(str As String) As String
            Return EncryptString(str)
        End Function
    
        Public Shared Function GenarateSalt() As String
    
            Using cryptoServiceProvider As New Security.Cryptography.RNGCryptoServiceProvider
                Dim StrBuilder As New Text.StringBuilder
                Dim data As Byte() = New Byte(4) {}
                For i = 0 To 6
                    cryptoServiceProvider.GetBytes(data)
                    Dim value As String = BitConverter.ToString(data, 0)
                    StrBuilder.Append(value)
                Next
                Return EncryptString(StrBuilder.ToString())
            End Using
    
        End Function
    
        Private Shared Function EncryptString(str As String) As String
            Dim bytes As Byte() = Text.Encoding.ASCII.GetBytes(str)
            Dim hashed = Security.Cryptography.SHA256.Create().ComputeHash(bytes)
            Return Convert.ToBase64String(hashed)
        End Function

    Note: there is SQLite.Interop.dll included in both 64x and 89x folders in debug 

    Thank you....


    RohanD

    Monday, February 17, 2020 5:30 AM

Answers

  • Hi RAT_SL,

    Thanks for your feedback.

    I use SQLServer database to make a test based on your code.

    I find that if 'Salt' is unique to each password, then you should get the correct value of 'hashedandsalted'.

    You need to make sure that when you insert into the database, value of 'Salt' is correctly stored.

    Hope it can help you.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.




    Tuesday, February 18, 2020 6:55 AM
    Moderator

All replies

  • If this Login button has a handler, did you put a breakpoint in the code, click Login and try investigating the problem using Debugger step-by-step?

    Monday, February 17, 2020 8:14 AM
  • Hi Rohan Danushka,

    Thank you for posting here.

    According to your code, I need more information to make a test.

    Could you provide some related code about 'DBManager.Login'? It will help us to make a test.

    We are waiting for your update.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, February 17, 2020 10:07 AM
    Moderator
  • Ok, Please wait

    RohanD

    Monday, February 17, 2020 11:25 AM
  • Public Shared Sub Login(username As String, password As String)
            Dim salt As String = ""
    
            Using sqlconn As New SQLiteConnection(connection)
                Dim readsaltquery As String = "SELECT * FROM database WHERE UN=@un"
                Dim sqlcommand As New SQLiteCommand(readsaltquery, sqlconn)
                sqlcommand.Parameters.AddWithValue("@un", username)
    
                If connection.State = ConnectionState.Open Then
                    Dim reader As SQLiteDataReader = sqlcommand.ExecuteReader(readsaltquery)
                    While reader.Read
                        salt = reader("Salt").ToString
                    End While
                    reader.Close()
    
                    Dim pass = Encryption.HashString(password)
                    Dim hashedandsalted = Encryption.HashString(String.Format("{0}{1}", pass, salt))
    
                    MsgBox("Password : " & pass & vbCrLf & "Hash+Solt : " & hashedandsalted)
    
                    Dim checkloginquery As String = "SELECT COUNT(*) FROM database WHERE UN=@user AND HashandSalt=@pass"
                    Dim sqlcommend0 As New SQLiteCommand(checkloginquery, sqlconn)
                    sqlcommend0.Parameters.AddWithValue("@user", username)
                    sqlcommend0.Parameters.AddWithValue("@pass", hashedandsalted)
                    Dim result As Integer = Convert.ToInt32(sqlcommend0.ExecuteScalar)
                    If result = 1 Then
                        sqlcommend0.Dispose()
                        MsgBox("welcome" & username)
                        Form2.TextBox1.Text = ""
                        Form2.TextBox2.Text = ""
                        Form2.Hide()
                        Form1.Show()
                    Else
                        MsgBox("Wrong Data... SOrry")
                        Form2.TextBox1.Text = ""
                        Form2.TextBox2.Text = ""
                        Form2.TextBox1.Select()
                    End If
                End If
            End Using
        End SubMake a suggestion


    RohanD

    Monday, February 17, 2020 11:27 AM
  • Hi RAT_SL,

    Thanks for your feedback.

    I use SQLServer database to make a test based on your code.

    I find that if 'Salt' is unique to each password, then you should get the correct value of 'hashedandsalted'.

    You need to make sure that when you insert into the database, value of 'Salt' is correctly stored.

    Hope it can help you.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.




    Tuesday, February 18, 2020 6:55 AM
    Moderator
  • Hi Zhao,

    Thanks for the reply. but unfortunately my all previous projects that use SQLite have same issue. please see the screen shot. 

    They all are not reading SQLite DB's now. and they can save data as same as before. 

    As i see SQLite native library keep try to load when data reading... isn't?

     


    RohanD

    Tuesday, February 18, 2020 9:23 AM
  • Hi RAT_SL,

    Since I don't have SQLLite native library, in order to find the cause of the problem, you can use SQL Server Object Explorer to connect to sql server, and make a test again.

    If the code works well, then the problem may related to your database.

    Besides, if you get any exceptions, please provide your code about 'Add User'.

    We are waiting for your update.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, February 19, 2020 6:42 AM
    Moderator
  • Thank you so much.... Just now I found the issue. all works fine now... any way you are voted...

    (O_O)HappyCoding#  

    <iframe __idm_frm__="113" class="ginger-extension-definitionpopup" style="display:none;"></iframe>

    RohanD

    Wednesday, February 19, 2020 9:52 PM