Results 1 to 14 of 14

Thread: [RESOLVED] Help resolve this SIMPLE problem

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2008
    Posts
    159

    Resolved [RESOLVED] Help resolve this SIMPLE problem

    First off I am SO tired it's not even funny!

    I am trying to make sure my encrypt and decrypt functions are working
    properly.

    I was testing them out when I accidentally lost my work.

    I have put everything back together and I'm exhausted and I can't figure
    out where I am going wrong with this.

    Basically I'm taking a value from textbox1 and decrypting it and showing that
    value in textbox 2. Simple right?

    Here is the code for the decrypt button, how would I then call for the value
    in textbox 2?

    Code:
    Dim strArray As String() = Me.Decrypt(TextBox1.Text).Split(New Char() {"|"c})
            TextBox2 = ?
    Here is the decrypt function:

    Code:
     Public Function Decrypt(ByVal ciphertext As String) As String
            Dim str2 As String
            Dim str3 As String = DateTime.UtcNow.Hour.ToString.PadLeft(2, "0"c)
            Dim bytes As Byte() = Encoding.UTF8.GetBytes(("GpWhFbntD" & str3.ToString & "Qpop38D@dUnrF"))
            Dim rgbIV As Byte() = Encoding.UTF8.GetBytes("wFyEQPdN")
            Dim provider As New TripleDESCryptoServiceProvider With { _
                .BlockSize = &H40, _
                .Padding = PaddingMode.Zeros _
            }
            Using stream As MemoryStream = New MemoryStream
                Using stream2 As CryptoStream = New CryptoStream(stream, provider.CreateDecryptor(bytes, rgbIV), CryptoStreamMode.Write)
                    Dim buffer As Byte() = Convert.FromBase64String(ciphertext)
                    stream2.Write(buffer, 0, buffer.Length)
                    stream2.FlushFinalBlock()
                    str2 = Encoding.UTF8.GetString(stream.ToArray)
                End Using
            End Using
            Return str2
        End Function
    -Chris
    Last edited by cmmorris1; Aug 14th, 2011 at 08:48 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width