A Kaiser cipher algorithm based on VBS _VBS

Source: Internet
Author: User
Tags chr
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.