Results 1 to 3 of 3

Thread: encrypt string problem

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    encrypt string problem

    Hi there

    i seem to be having an "Invalid length of data" problem when i am trying to encrypt a string

    I am using tripleDES

    Code:
    Public Function EncryptString(ByVal InputString As String) As String
    
            Dim data As Byte()
            Dim dest As Byte()
            Dim transform As ICryptoTransform
    
            data = Encoding.Default.GetBytes(InputString)
    
            transform = des.CreateDecryptor
            dest = transform.TransformFinalBlock(data, 0, data.Length) '<< HERE!!!!
    
            Return Convert.ToBase64String(dest, 0, dest.Length)    
    End Function
    any ideas?

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: encrypt string problem

    anyone?

  3. #3
    Addicted Member WALDO's Avatar
    Join Date
    Aug 2002
    Location
    Swing of Prussia, PA
    Posts
    244

    Re: encrypt string problem

    It seems to me that dest and data have to be the same size. Try re-dimensioning dest to the same size as data.
    VB Code:
    1. transform = des.CreateDecryptor
    2. ReDim dest(data.Length - 1)
    3. dest = transform.TransformFinalBlock(data, 0, data.Length)
    This is just a guess.

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