⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 viginear.cs

📁 使用viginear,column permutation,DES加密和解密
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;

namespace MyCAP
{
    class viginear
    {
        public string GetCipher(string plain, string key)
        {
            int i, j = 0;// i for  circle , j for remember the position of char in key
            int tem;//for remembering the cipher number
            string cipher = null;
            for (i = 0; i < plain.Length; i++)
            {
                if (j == key.Length)
                    j = 0;
                tem = (int)plain[i] + (int)key[j++] - (int)'a';
                if (tem > 'z')
                    tem = tem - 26;
                cipher += (char)tem;
            }
            return cipher;
        }

        public string Getplain(string cipher, string key)
        {
            int i, j = 0;// i for  circle , j for remember the position of char in key
            int tem;//for remembering the cipher number
            string plain = null;
            for (i = 0; i < cipher.Length; i++)
            {
                if (j == key.Length)
                    j = 0;
                tem = (int)cipher[i] - (int)key[j++] + (int)'a';
                if (tem < 'a')
                    tem = tem + 26;
                plain += (char)tem;
            }
            return plain;
        }

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -