In cryptography, Caesar's code (or Caesar's encryption, Caesar's transformation) is one of the simplest and most widely known cryptographic techniques. It is a technique for replacing encryption, in which all letters in plaintext are replaced by a fixed number of Cheng Mi-wen (or forward) after the alphabet is offset. For example, when the offset is 3, all the letters A will be replaced with D,B into E, and so on. This method of encryption was named after Caesar, who had used this method to communicate with his generals.
For example, when the offset is left 3 (the key at the time of decryption is 3):
Copy Code code as follows:
PlainText Alphabet: abcdefghijklmnopqrstuvwxyz
Cipher Letter: DEFGHIJKLMNOPQRSTUVWXYZABC
Above all is nonsense, recently teaching a child VBS, gave her a problem, let her realize Caesar cipher algorithm, but seemingly a bit difficult. Google a little Caesar password, out of the basic is C and Java implementation, or I write it myself.
Copy Code code as follows:
Function Caesar (Str,offset)
Dim Length,char,i
Caesar = ""
Length = Len (str)
For i = 1 to length
char = Mid (str,i,1)
If Char >= "A" and char <= "Z" Then
char = ASC ("a") + (ASC (char)-ASC ("A") + offset) Mod 26
Caesar = Caesar & Chr (char)
ElseIf Char >= "a" and char <= "Z" Then
char = ASC ("a") + (ASC (char)-ASC ("a") + offset) Mod 26
Caesar = Caesar & Chr (char)
Else
Caesar = Caesar & Char
End If
Next
End Function
WScript.Echo Caesar ("ABCDEFGHIJKLMNOPQRSTUVWXYZ", 3)
WordPress's default theme is really not good, the code unexpectedly overflow, will see it, or recommend me a better topic to watch the line.
Original: http://demon.tw/programming/vbs-caesar.html