Solved

calculating legth of triple DES  encrypted string

Posted on 2009-04-07
5
489 Views
Last Modified: 2012-05-06
I am encrypting a varchar(30) column and storing in a different column in the database.

I need to calculate what the maximum length of the encrypted text could be so that I can make sure the new column is the right size. How do I calculate the size?

I am using vb.net to do the encryption and SQL server 2005 to store the data.
0
Comment
Question by:darrenwright
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 12

Expert Comment

by:udaya kumar laligondla
ID: 24087691
for a 30 character string it will be approximately 36 chars. you can use the following caluculation to calculate the length n + 8 - (n % 8)
where n is the length of the source string
0
 

Author Comment

by:darrenwright
ID: 24088329
I'm get back encryption strings of 88 chars so something not right
0
 
LVL 12

Expert Comment

by:udaya kumar laligondla
ID: 24088695
0
 

Author Comment

by:darrenwright
ID: 24088866
I use encrypttostring function
        Public Overloads Function EncrypttoString(ByVal plainText As String) As String
        Return Convert.ToBase64String(Encrypt(plainText))
    End Function
Public Function Encrypt(ByVal plainText As String) As Byte()
 
        Dim tdes As New TripleDESCryptoServiceProvider()
        Dim encryptor As ICryptoTransform = tdes.CreateEncryptor(mvarTripleDesKey, mvarTripleIV)
        Dim data As Byte() = Encoding.Unicode.GetBytes(plainText)
 
        Return encryptor.TransformFinalBlock(data, 0, data.Length)
 
    End Function

Open in new window

0
 
LVL 12

Accepted Solution

by:
udaya kumar laligondla earned 500 total points
ID: 24093483
you are using three conversions (for 30 chars)
1.  unicode ( 30 *2 = 60)
2.encryption ( 60 +8 (60 % 8) = 64 (63.2))
3. Base64 Encoding (88)  calculated as Base64 = ((64 + 3 - (64 MOD 3)) /3) x 4

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When the confidentiality and security of your data is a must, trust the highly encrypted cloud fax portfolio used by 12 million businesses worldwide, including nearly half of the Fortune 500.
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question