Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi everyone, I need to create a vb6 codes contains the Caeser Cipher (the mathematical method)
C = E(p) = (p + k) mod (26)


My friend just created a code in C# but i need to convert it to vb6 (but without using a function, because i am not good in this)

appreciate if someone can assist me with this

C#
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.ComponentModel.Composition;

    public class Ceaser : SecurityAlgorithm
    {
        readonly int key;

        #region Constructor

        public Ceaser(int key)
        {
            this.key = key;
        }

        #endregion

        #region Public Methods

        public override string Encrypt(string plainText)
        {
            return Process(plainText, Mode.Encrypt);
        }

        public override string Decrypt(string cipher)
        {
            return Process(cipher, Mode.Decrypt);
        }

        #endregion

        #region Private Methods

        private string Process(string message, Mode mode)
        {
            string result = string.Empty;

            foreach (char c in message)
            {
                var charposition = alphabet[c];
                var res = Common.GetAlphabetPosition(charposition, key, mode);
                result += alphabet.Keys.ElementAt(res % 26);
            }

            return result;
        }

        #endregion
    }
}
Posted
Updated 8-May-15 2:08am
v2

1 solution

Sounds like homework, however see an implementation at freevbcode[^].

There are other implementations[^] in VB6 out there.
 
Share this answer
 
Comments
Maciej Los 8-May-15 8:49am    
+5
Duha920 8-May-15 10:33am    
Thank you dear, I will check that :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900