Re: Encryption & Decryption
Quote:
Originally Posted by Vanasha
. . . I don't know if anyone else has done this before or whatever
A few times:
http://vbforums.com/showthread.php?t=292138
http://vbforums.com/showthread.php?t=404980
http://vbforums.com/showthread.php?t=311963
BTW, nice piece of code :thumb:
Re: Encryption & Decryption
Hehe, thanks. I didn't know anyone else did it.. but hey. :D
Re: Encryption & Decryption
Here's just a few quick suggestions if you don't mind:
1. Don't pass the Password and Text arguments as ByVal.
2. Don't use string concatenation (String1 = String1 & Something). In your case, the output will always be the same length as the input so you can buffer enough space to store the output before-hand:
EncryptF = Space$(Len(Text))
And instead of:
EncryptF = EncryptF & Chr(Temp)
You could have:
Mid$(EncryptF, i, 1) = Chr$(Temp)
3. Which is important, your code will have problems encrypting some text because there is a possibility the new char (Temp) will exceed 255 (and in decryption, be negative). This will cause an error and won't encrypt the whole text:
Temp = Asc(Mid(Text, i, 1)) + Asc(Mid(Password, i, 1))
If the sum of those is greater than 255 then you will have problems. Or in decrypt, if they are less than 0 then you will get errors.
Re: Encryption & Decryption
And use vbNullString instead of "" ;)
Re: Encryption & Decryption
Re: Encryption & Decryption
Re: Encryption & Decryption
Quote:
Originally Posted by CVMichael
Sorry :blush: :blush: :blush: