1. 同音代換加密法
namespace Q1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
var data = """
09 12 33 47 53 67 78 92
48 81
13 41 62
01 03 45 79
14 16 24 44 46 55 57 64 74 82 87 98
10 31
06 25
23 39 50 56 65 68
32 70 73 83 88 93
15
""".Split("\n").Select(e => e.Split(" ").Select(int.Parse).ToList()).ToList();
string o = "";
Dictionary<char, int> freq = new Dictionary<char, int>();
foreach (var item in textBox1.Text)
{
var c = (char)(item - 'a');
int f = freq.GetValueOrDefault(c, 0);
o += (data[c][f % data[c].Count]).ToString().PadLeft(2, '0') + " ";
freq[c] = f + 1;
}
if (o.Length != 0) o = o.Substring(0, o.Length - 1);
textBox2.Text = o;
}
}
}Last updated