📄 viginear.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 + -