Page view counter

RSA Cryptology problem

Last post 08-17-2003 4:32 PM by tmw06. 1 replies.

Sort Posts:

  • RSA Cryptology problem

    08-15-2003, 6:57 AM
    • Loading...
    • mtullock
    • Joined on 11-28-2002, 3:40 AM
    • Posts 4
    • Points 20
    Hi, I have the following encryption code:


    Dim encryptedKey As String = nothing
    <WebMethod()> Public Function Encrypt(ByVal password As String) As String
    Dim bEncryptedData() As Byte
    Dim rsaCSP As RSACryptoServiceProvider
    Dim bInput() As Byte
    Dim paramCSP As CspParameters
    paramCSP = New CspParameters()

    paramCSP.Flags = CspProviderFlags.UseMachineKeyStore
    rsaCSP = New RSACryptoServiceProvider(paramCSP)

    bInput = (New System.Text.UnicodeEncoding()).GetBytes(password)

    encryptionKey = rsaCSP.ToXmlString(True)

    bEncryptedData = rsaCSP.Encrypt(bInput, False)
    Encrypt = (New System.Text.UnicodeEncoding()).GetString(bEncryptedData).ToString()
    End Function


    This works great, it generates a key and the pwd which I can then store in our DB, however, what I want to do now is use the existing key from the DB to encrypt another PWD to see if they match -- any idea how I can get the above code to use the encryptedKey string as teh encryption key??? ( I realise there are other password encryption methods but I have been playing with this one for too ling to give up now :) )

    Cheers
    Magnus
  • Re: RSA Cryptology problem

    08-17-2003, 4:30 PM
    • Loading...
    • tmw06
    • Joined on 09-16-2002, 7:04 AM
    • Posts 4
    • Points 27
    Instead of encrypting with keys I would suggest doing a one-way hash using MD5.Create("somepassword"). Store the hashed value in your database. When a user logs on, take the password they entered and has that password and compare it to the hashed value in the database.
Page 1 of 1 (2 items)