📄 viewencryptedtext.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace EncrySMS
{
public partial class ViewEncryptedForm : Form
{
public ViewEncryptedForm()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Enabled = false;
Close();
}
public static void ShowDecryptContent(string EncryptedContent,ref bool bAutoClose)
{
ViewEncryptedForm form = new ViewEncryptedForm();
form.edtEncrypt.Text = EncryptedContent;
form.chbAutoClose.Checked = bAutoClose;
form.ShowDialog();
bAutoClose = form.chbAutoClose.Checked;
form = null;
}
private void ViewEncryptedForm_Activated(object sender, EventArgs e)
{
if (chbAutoClose.Checked)
{
timer1.Enabled = true;
btnPin.Text = "钉住";
}
else
btnPin.Text = "关闭";
}
private string Decrypt(string content)
{
if (content.Substring(0, 4) != "zzzz")
return content;
char[] tmp = content.Substring(4).ToCharArray();
byte[] encryptedbyte = new byte[2];
char[] encrypedchars = new char[tmp.Length];
for (int i = 0; i < tmp.Length; i++)
{
byte[] charbyte = BitConverter.GetBytes(tmp[i]);
if (charbyte[1] == 0)
{
encryptedbyte[1] = 0;
if (charbyte[0] >= 0x20 && charbyte[0] <= 0x7e)//visible char
{
encryptedbyte[0] = (byte)(charbyte[0] - (byte)0x5);
if (encryptedbyte[0] < 0x20)
encryptedbyte[0] = (byte)(encryptedbyte[0] - 0x20 - (0xff - 0x7e));
}
else
encryptedbyte[0] = charbyte[0];
}
else
{
encryptedbyte[0] = (byte)((charbyte[0] - 0x7) );
encryptedbyte[1] = (byte)((charbyte[1] - 0x7) );
}
encrypedchars[i] = BitConverter.ToChar(encryptedbyte, 0);
}
return new string(encrypedchars);
}
private void edtEncrypt_TextChanged(object sender, EventArgs e)
{
edtDecrypt.Text = Decrypt(edtEncrypt.Text);
}
private void btnPin_Click(object sender, EventArgs e)
{
if (btnPin.Text=="钉住")
{
timer1.Enabled = false;
btnPin.Text = "关闭";
}
else
{
Close();
}
}
private void ViewEncryptedForm_Closing(object sender, CancelEventArgs e)
{
timer1.Enabled = false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -