Posted By

blackf0rk on 03/12/09


Tagged

simple Encryption


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

Scooter
mjnbrn
haoji


Simple String Encryption


 / Published in: VB.NET
 

URL: http://codefinds.blogspot.com/2009/01/simple-string-encryption.html

Passing in a seed and your string will return an encrypted string. Pass in the same seed and the encrypted string again and it will return the original unencrypted string.

  1. Public Function EncryptString(ByVal InSeed As Integer, ByVal InString As String) As String
  2. Dim c1 As Integer
  3. Dim NewEncryptString As String
  4. Dim EncryptSeed As Integer
  5. Dim EncryptChar As String
  6.  
  7. NewEncryptString = ""
  8. EncryptSeed = InSeed
  9. For c1 = 1 To Len(InString)
  10. EncryptChar = Mid(InString, c1, 1)
  11. EncryptChar = Chr(Asc(EncryptChar) Xor EncryptSeed)
  12. EncryptSeed = EncryptSeed Xor c1
  13. NewEncryptString = NewEncryptString & EncryptChar
  14. Next
  15.  
  16. EncryptString = NewEncryptString
  17. End Function

Report this snippet  

You need to login to post a comment.