Caesar cryptographic algorithm implemented with vbs

Source: Internet
Author: User

In cryptography, the Caesar password (also known as Caesar encryption and Caesar transformation) is the simplest and most widely known encryption technology. It is a technology to replace encryption. All the letters in plain text are shifted backward (or forward) to a fixed number in the alphabet and then replaced with a secret. For example, when the offset is 3, all letters A are replaced with D, B is changed to E, and so on. This encryption method was named by Caesar, who used this method to contact the generals.

For example, when the offset is shifted to 3 (the decryption key is 3 ):

CopyCode The Code is as follows: plaintext alphabet: abcdefghijklmnopqrstuvwxyz
Ciphertext alphabet: defghijklmnopqrstuvwxyzabc

The above is all nonsense. I recently taught a kid vbs to give her a question and let her implement the Caesar password.AlgorithmBut it seems a little difficult. Google the Caesar password, which is basically implemented in C and Java. Let's write it by myself.

Copy code The Code is 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)

The default theme of WordPress is really bad, and the code overflows. You can check it out, or recommend me a nice theme.

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.