Todd_Anderson
asked on
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 TripleDESCryptoServiceProv ider
Private MD5 As New MD5CryptoServiceProvider
Private Key As String = "ThisWouldBeTheKey"
Public Function Encrypt(ByVal InputString As String)
DES.Key = MD5.ComputeHash(ASCIIEncod ing.ASCII. GetBytes(K ey))
DES.Mode = CipherMode.ECB
Dim Buffer As Byte() = ASCIIEncoding.ASCII.GetByt es(InputSt ring)
Return Convert.ToBase64String(DES .CreateEnc ryptor().T ransformFi nalBlock(B uffer, 0, Buffer.Length))
End Function
Is there a way to determine if the string is encrypted or not?
Thanks,
Todd
Private DES As New TripleDESCryptoServiceProv
Private MD5 As New MD5CryptoServiceProvider
Private Key As String = "ThisWouldBeTheKey"
Public Function Encrypt(ByVal InputString As String)
DES.Key = MD5.ComputeHash(ASCIIEncod
DES.Mode = CipherMode.ECB
Dim Buffer As Byte() = ASCIIEncoding.ASCII.GetByt
Return Convert.ToBase64String(DES
End Function
Is there a way to determine if the string is encrypted or not?
Thanks,
Todd
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
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.
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.
ASKER
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
Thanks for the help.
Todd
ASKER
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