Unable to decrypt string over 7 characters long using 3DES wrapper


Author
Message
Keith Chisarik
Keith Chisarik
StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)
Group: StrataFrame Users
Posts: 939, Visits: 40K
thanks Trent, that lead me to the answer. I had written a quick program that encrypted the field data a few days ago, by bad luck the field was not long enough for all the new values since the encryption algorithm adds to the length, some were OK but some got truncated and since they were encrypted it didnt catch my eye and the error lead me down the wrong path.

Now, all is good except I have browse dialogs that use the encrypted field to search, they are using the raw encrypted field data from the server, returning incorrect records. How can I make them use the decrypted values like I set in my BO field property?

I know the BD creates the query dynamically and I think that is can only use actual fields and not custom (or customized) ones (???) so I am not sure how to accomplish my goal, to allow the encrypted field (SSN) to be included in the BD as a search field (with advanced options).

Keith

Keith Chisarik

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Keith,

I am unsure of what your code may look like as I have tested this using your example and it all seems to work fine.  Also, this is a class that we use extensively in the framework and within our medical software as well, so I am pretty confident that it is sound.  But just in case, I created a sample that works and have attached it here.  You can tweak it and let me know if you are doing something else that will spawn the error.  But you might look at this sample and see if you are doing something outside of these specs.

Attachments
3DESSample.zip (174 views, 68.00 KB)
Keith Chisarik
Keith Chisarik
StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)
Group: StrataFrame Users
Posts: 939, Visits: 40K
It (3DES Wrapper) will encrypt them, but any attempt to decrypt a string greater than 7 characters generates the error Invalid length for a Base-64 char array. I have reproduced on several machines running 1.6.6 using very simple code to decrypt and enrypt a string (no BO's, no custom anything).

For example "1111111" encrypts and decrypts fine, but "11111111" will encrypt but not decrypt.

Any insight appreciated as always.

The occurs in tripledeswrapper.vb at the function Decrypt, in the first line of the function:

Public Function Decrypt(ByVal text As String) As String

Dim input() As Byte = Convert.FromBase64String(text)

Dim output() As Byte = Transform(input, m_des.CreateDecryptor(m_key, m_iv))

Return m_utf8.GetString(output)

End Function



Keith Chisarik
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search