How can I tell if a string is encrypted?

I have a string that may or may not be encrypted.  The code used to encrypt the string, if it is encrypted, is below.

    Private DES As New TripleDESCryptoServiceProvider
    Private MD5 As New MD5CryptoServiceProvider
    Private Key As String = "ThisWouldBeTheKey"

    Public Function Encrypt(ByVal InputString As String)
        DES.Key = MD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(Key))
        DES.Mode = CipherMode.ECB

        Dim Buffer As Byte() = ASCIIEncoding.ASCII.GetBytes(InputString)

        Return Convert.ToBase64String(DES.CreateEncryptor().TransformFinalBlock(Buffer, 0, Buffer.Length))
    End Function

Is there a way to determine if the string is encrypted or not?

Thanks,

Todd
Todd_AndersonAsked:
Who is Participating?
 
dstanley9Commented:
No definite way that I know of.  There may be clues - length of the string, presence of certain characters, etc.

Why is the string only encrypted part of the time?
0
 
Todd_AndersonAuthor Commented:
Its a long story on why the string may or may not be encrypted.  Not really the issue here though.

I was just looking at the encrypted strings and all of the longer ones have double equal signs at the end (==) and the shorter ones have single equals signs at the end (=).  Every hear of this being a sign of encryption?

Todd
0
 
dstanley9Commented:
Base64 pads strings with equals signs if the encoded string's length is not a multiple of 3.  Every three bytes are encoded into 4 ASCII characters.  If the source string does not contain an even multiple of three characters, one or two equals signs are added to indicate how long the last triplet is.

http://en.wikipedia.org/wiki/Base_64

However, Base64 is an encoding method, not an encryption method.  It is a way to encode binary data into a smaller subset of characters to be transmitted without having to support all 256 possible values of a byte.  There is no guarantee that the encoded string will contain an equals sign.  In fact if the lengths of the strings are random, then statistically one out of every three strings will NOT have an equals sign.  

Even if you know the string is base-64, you still don't know if the source string is the original source or an encrypted version.  
0
 
Todd_AndersonAuthor Commented:
Ok, I guess I will have to look at one of my backup plans.  I was hoping that I could detect the encryption since it is the most straight forward.

Thanks for the help.

Todd
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.