Let's create our own encryption code without using the existing encryption method like md5 or hash.
The Code below shows a simple trick on how to handle the Encryption using the loop, chr, asc, and mid method.
ChrW method returns a String containing the Unicode character except on platforms where Unicode is not supported, in which case, the behavior is identical to the Chr function. Chr() method that works in Visual Basic but I don't know in C# code.
AscW function returns the Unicode character code except on platforms where Unicode is not supported, in which case, the behavior is identical to the Asc function.
Mid function to return a specified number of characters from a string.
Encrypt
Function Encrypt(ByVal Inputtxt As String) Encrypt = "" Dim CharCount As Integer For CharCount = 1 To Len(Inputtxt) Encrypt = Encrypt + Chr(Asc(Mid(Inputtxt, CharCount, 1)) + 15) Next CharCount End Function
Decrypt
Function Decrypt(ByVal Inputtxt As String) Decrypt = "" Dim CharCount As Integer For CharCount = 1 To Len(Inputtxt) Decrypt = Decrypt + Chr(Asc(Mid(Inputtxt, CharCount, 1)) - 15) Next CharCount End Function
Image below show's how to use this code
No comments:
Post a Comment