黑吧专用破解计算器源码,在此发布一下,希望能交一些C#编程方面的朋友。。。
//软件名称:黑吧专用破解计算器源码
//开发环境:C#语言,VS2008环境
//作者:冰河之刃
// QQ:290113866
//日期:2009年10月21日17时55分53秒
using System;
using System.Windows.Forms;
namespace PoJieHelper
{
public partial class Form1 : Form, System.IFormatProvider
{
public Form1()
{
InitializeComponent();
}
/*
* 字符串运算开始
* **/
private void btn_go_Click(object sender, EventArgs e)/*字符串转换*/
{
try
{
string pwdinfo = "";
int sum10 = 0;
string hexall = "";
string str = txt_string.Text.Trim();
for (int i = 0; i < str.Length; i++)
{
char b = (char)str[i];
int t = (int)b;
hexall += Convert.ToString(t, 16).ToString();
sum10 += t;
pwdinfo += t;
}
txt_ascii.Text = pwdinfo;
txt_sum10.Text = sum10.ToString();
txt_sum16.Text = Convert.ToString(sum10, 16);
txt_asciito16.Text = hexall;
}
catch
{
MessageBox.Show("程序出错,请重新启动本程序,注意检查输入的格式", "程序出错");
}
}
private void btn_clearclear_Click(object sender, EventArgs e)/*清空*/
{
txt_string.Text = "";
txt_ascii.Text = "";
txt_asciito16.Text = "";
txt_sum10.Text = "";
txt_sum16.Text = "";
}
/*
*字符串运算完--------------数学运算模块
* **/
private void btn_add_Click(object sender, EventArgs e)/*加法*/
{
if (rdb_ten.Checked)/*若选中十进制*/
{
try
{
double add1 = double.Parse(txt_add1.Text);
double add2 = double.Parse(txt_add2.Text);
double add3 = add1 + add2;
txt_add3.Text = add3.ToString();
}
catch
{
MessageBox.Show("输入数据不合法或位数太长!请重新输入!", "警告:");
}
}
else if (rdb_hex.Checked)/*若选中十六进制*/
{
try
{
string add1 = txt_add1.Text.Trim();
string add2 = txt_add2.Text.Trim();
long a1 = Convert.ToInt64(add1,16);
long a2 = Convert.ToInt64(add2,16);
long a3 = a1 + a2;
string a4 = Convert.ToString(a3,16);
txt_add3.Text = a4.ToString();
}
catch
{
MessageBox.Show("输入数据不合法或位数太长!请重新输入!", "警告:");
}
}
}
private void btn_min_Click(object sender, EventArgs e)/*减法*/
{
if (rdb_ten.Checked)/*若选中十进制*/
{
try{
double min1 = double.Parse(txt_min1.Text);
double min2 = double.Parse(txt_min2.Text);
double min3 = min1 - min2;
txt_min3.Text = min3.ToString();
}
catch
{
MessageBox.Show("输入数据不合法或位数太长!请重新输入!", "警告:");
}
}
else if (rdb_hex.Checked)/*若选中十六进制*/
{
try
{
string min1 = txt_min1.Text.Trim();
string min2 = txt_min2.Text.Trim();
long m1 = Convert.ToInt64(min1, 16);
long m2 = Convert.ToInt64(min2, 16);
long m3 = m1-m2;
string m4 = Convert.ToString(m3, 16);
txt_min3.Text = m4.ToString();
}
catch
{
MessageBox.Show("输入数据不合法或位数太长!请重新输入!", "警告:");
}
}
}
private void btn_mul_Click(object sender, EventArgs e)/*乘法*/
{
if (rdb_ten.Checked)/*若选中十进制*/
{
try
{
double mul1 = double.Parse(txt_mul1.Text);
double mul2 = double.Parse(txt_mul2.Text);
double mul3 = mul1 * mul2;
txt_mul3.Text = mul3.ToString();
}
catch
{
MessageBox.Show("输入数据不合法或位数太长!请重新输入!", "警告:");
}
}
else if (rdb_hex.Checked)/*若选中十六进制*/
{
try
{
string mul1 = txt_mul1.Text.Trim();
string mul2 = txt_mul2.Text.Trim();
long m1 = Convert.ToInt64(mul1,16);
long m2 = Convert.ToInt64(mul2,16);
long m3 = m1 * m2;
string m4 = Convert.ToString(m3,16);
txt_mul3.Text = m4.ToString();
}
catch
{
MessageBox.Show("输入数据不合法或位数太长!请重新输入!", "警告:");
}
}
}
private void btn_div_Click(object sender, EventArgs e)/*除法*/
{
if (rdb_ten.Checked)/*若选中十进制*/
{
try
{
double div1 = double.Parse(txt_div1.Text);
double div2 = double.Parse(txt_div2.Text);
if(div2==0)
{
MessageBox.Show("被除数不能为0!请重新输入!", "警告:");
return;
}
double div3 = div1 / div2;
txt_div3.Text = div3.ToString();
}
catch
{
MessageBox.Show("输入数据不合法或位数太长!请重新输入!", "警告:");
}
}
else if (rdb_hex.Checked)/*若选中十六进制*/
{
try
{
string div1 = txt_div1.Text.Trim();
string div2 = txt_div2.Text.Trim();
long d1 = Convert.ToInt64(div1,16);
long d2 = Convert.ToInt64(div2,16);
if (div2.Equals("0"))
{
MessageBox.Show("被除数不能为0!请重新输入!", "警告:");
return;
}
long d3 = d1 / d2;
string d4 = Convert.ToString(d3,16);
txt_div3.Text = d4.ToString();
}
catch
{
MessageBox.Show("输入数据不合法或位数太长!请重新输入!", "警告:");
}
}
}
private void btn_yu_Click(object sender, EventArgs e)/*取余数*/
{
if (rdb_ten.Checked)/*若选中十进制*/
{
try
{
double yu1 = double.Parse(txt_yu1.Text);
double yu2 = double.Parse(txt_yu2.Text);
if (yu2 == 0)
{
MessageBox.Show("被余之数不能为0!请重新输入!", "警告:");
return;
}
double yu3 = yu1 %yu2;
txt_yu3.Text = yu3.ToString();
}
catch
{
MessageBox.Show("输入数据不合法或位数太长!请重新输入!", "警告:");
}
}
else if (rdb_hex.Checked)/*若选中十六进制*/
{
try
{
string yu1 = txt_yu1.Text.Trim();
string yu2 = txt_yu2.Text.Trim();
long y1 = Convert.ToInt64(yu1,16);
long y2=Convert.ToInt64(yu2,16);
if (yu2.Equals("0"))
{
MessageBox.Show("被余之数不能为0!请重新输入!", "警告:");
return;
}
long y3 = y1 % y2;
string y4 = Convert.ToString(y3,16);
txt_yu3.Text = y4.ToString();
}
catch
{
MessageBox.Show("输入数据不合法或位数太长!请重新输入!", "警告:");
}
}
}
private void btn_clearthis_Click(object sender, EventArgs e)/*全部清除*/
{
txt_add1.Text = "";
txt_add2.Text = "";
txt_add3.Text = "";
txt_min1.Text = "";
txt_min2.Text = "";
txt_min3.Text = "";
txt_mul1.Text = "";
txt_mul2.Text = "";
txt_mul3.Text = "";
txt_div1.Text = "";
txt_div2.Text = "";
txt_div3.Text = "";
txt_yu1.Text = "";
txt_yu2.Text = "";
txt_yu3.Text = "";
}
/*
* 数学运算模块完------逻辑运算开始
* **/
private void btn_xor_Click(object sender, EventArgs e)/*异或运算*/
{
try
{
if (rdb_10.Checked)
{
int xor1 = int.Parse(txt_xor1.Text.Trim());
int xor2 = int.Parse(txt_xor2.Text.Trim());
int xor3 = (xor1 ^ xor2);
txt_xor3.Text = xor3.ToString();
}
else if (rdb_16.Checked)
{
string xor1 = txt_xor1.Text.Trim();
string xor2 = txt_xor2.Text.Trim();
int x1 = Convert.ToInt32(xor1, 16);
int x2 = Convert.ToInt32(xor2, 16);
int x3 = (x1 ^ x2);
string x4 = Convert.ToString(x3, 16);
txt_xor3.Text = x4.ToString();
}
}
catch
{
MessageBox.Show("输入数据不合法或位数太长!请重新输入!", "警告:");
}
}
private void btn_and_Click(object sender, EventArgs e)/*和运算*/
{
try
{
if (rdb_10.Checked)
{
int and1 = int.Parse(txt_and1.Text.Trim());
int and2 = int.Parse(txt_and2.Text.Trim());
int and3 = (and1 & and2);
txt_and3.Text = and3.ToString();
}
else if (rdb_16.Checked)
{
string and1 = txt_and1.Text.Trim();
string and2 = txt_and2.Text.Trim();
int a1 = Convert.ToInt32(and1, 16);
int a2 = Convert.ToInt32(and2, 16);
int a3 = (a1 & a2);
string a4 = Convert.ToString(a3, 16);
txt_and3.Text = a4.ToString();
}
}
catch
{
MessageBox.Show("输入数据不合法或位数太长!请重新输入!", "警告:");
}
}
private void btn_or_Click(object sender, EventArgs e)/*或运算*/
{
try
{
if (rdb_10.Checked)
{
int or1 = int.Parse(txt_or1.Text.Trim());
int or2 = int.Parse(txt_or2.Text.Trim());
int or3 = (or1 | or2);
txt_or3.Text = or3.ToString();
}
else if (rdb_16.Checked)
{
string or1 = txt_or1.Text.Trim();
string or2 = txt_or2.Text.Trim();
int o1 = Convert.ToInt32(or1, 16);
int o2 = Convert.ToInt32(or2, 16);
int o3 = (o1 | o2);
string or3 = Convert.ToString(o3, 16);
txt_or3.Text = or3.ToString();
}
}
catch
{
MessageBox.Show("输入数据不合法或位数太长!请重新输入!", "警告:");
}
}
private void btn_not_Click(object sender, EventArgs e)/*取反运算*/
{
try
{
if (rdb_10.Checked)
{
int not1 = int.Parse(txt_not1.Text.Trim());
int not2 = ~not1;
txt_not2.Text = not2.ToString();
}
else if (rdb_16.Checked)
{
string not1 = txt_not1.Text.Trim();
int n1 = Convert.ToInt32(not1, 16);
int n2 = ~n1;
string not2 = Convert.ToString(n2, 16);
txt_not2.Text = not2.ToString();
}
}
catch
{
MessageBox.Show("输入数据不合法或位数太长!请重新输入!", "警告:");
}
}
private void btn_left_Click(object sender, EventArgs e)/*左移*/
{
try
{
if (rdb_10.Checked)/*若选中十进制*/
{
long weiyi1 = long.Parse(txt_weiyi1.Text);
int weiyi2 = int.Parse(txt_weiyi2.Text);
long weiyi3 = weiyi1 << weiyi2;
txt_weiyi3.Text = weiyi3.ToString();
}
else if (rdb_16.Checked)/*若选中十六进制*/
{
string weiyi1 = txt_weiyi1.Text.Trim();
string weiyi2 = txt_weiyi2.Text.Trim();
int w1 = Convert.ToInt32(weiyi1, 16);
int w2 = Convert.ToInt32(weiyi2, 16);
int w3 = w1 << w2;
string w4 = Convert.ToString(w3, 16);
txt_weiyi3.Text = w4.ToString();
}
}
catch
{
MessageBox.Show("输入数据不合法或位数太长!请重新输入!", "警告:");
}
}
private void btn_right_Click(object sender, EventArgs e)/*右移*/
{
try
{
if (rdb_10.Checked)/*若选中十进制*/
{
long weiyi1 = long.Parse(txt_weiyi1.Text);
int weiyi2 = int.Parse(txt_weiyi2.Text);
long weiyi3 = weiyi1 >> weiyi2;
txt_weiyi3.Text = weiyi3.ToString();
}
else if (rdb_16.Checked)/*若选中十六进制*/
{
string weiyi1 = txt_weiyi1.Text.Trim();
string weiyi2 = txt_weiyi2.Text.Trim();
int w1 = Convert.ToInt32(weiyi1, 16);
int w2 = Convert.ToInt32(weiyi2, 16);
int w3 = w1 >> w2;
string w4 = Convert.ToString(w3, 16);
txt_weiyi3.Text = w4.ToString();
}
}
catch
{
MessageBox.Show("输入数据不合法或位数太长!请重新输入!", "警告:");
}
}
private void btn_clearmm_Click(object sender, EventArgs e)/*全部清除*/
{
txt_xor1.Text = "";
txt_xor2.Text = "";
txt_xor3.Text = "";
txt_and1.Text = "";
txt_and2.Text = "";
txt_and3.Text = "";
txt_or1.Text = "";
txt_or2.Text = "";
txt_or3.Text = "";
txt_not1.Text = "";
txt_not2.Text = "";
txt_weiyi1.Text = "";
txt_weiyi2.Text = "";
txt_weiyi3.Text = "";
}
/*
* 逻辑运算完
* **/
#region IFormatProvider 成员
public object GetFormat(Type formatType)
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
/*
* 进制转换开始
* **/
private void btn_change10_Click(object sender, EventArgs e)
{
try
{
long ten = long.Parse(txt_ten.Text.Trim());
string hex = Convert.ToString(ten, 16);
txt_hex.Text = hex.ToString();
txt_two.Text = Convert.ToString(ten,2);
txt_eight.Text = Convert.ToString(ten,8);
}
catch
{
MessageBox.Show("输入的数据长度可能过长或格式错误", "温馨提示:");
}
}
private void btn_change16_Click(object sender, EventArgs e)
{
try
{
string hex = txt_hex.Text.Trim(); //把从文本框中得到的数据转换为long型数据
long ten = Convert.ToInt64(hex, 16); //调用Convert函数来实现数据之间进制的转换
txt_ten.Text = ten.ToString(); //因为b已经是String类型了,就不需要转换了
txt_two.Text = Convert.ToString(ten, 2);
txt_eight.Text = Convert.ToString(ten, 8);
}
catch
{
MessageBox.Show("输入的数据长度可能过长或格式错误", "温馨提示:");
}
}
private void btn_change2_Click(object sender, EventArgs e)
{
try
{
string two = txt_two.Text.Trim();
long ten = Convert.ToInt64(two,2);
txt_ten.Text = ten.ToString();
txt_eight.Text = Convert.ToString(ten, 8);
txt_hex.Text = Convert.ToString(ten,16);
}
catch
{
MessageBox.Show("输入的数据长度可能过长或格式错误", "温馨提示:");
}
}
private void btn_change8_Click(object sender, EventArgs e)
{
try
{
string eight = txt_eight.Text.Trim();
long ten = Convert.ToInt64(eight, 8);
txt_ten.Text = ten.ToString();
txt_two.Text = Convert.ToString(ten,2);
txt_hex.Text = Convert.ToString(ten, 16);
}
catch
{
MessageBox.Show("输入的数据长度可能过长或格式错误", "温馨提示:");
}
}
private void btn_clearall_Click_1(object sender, EventArgs e)
{
txt_ten.Text = "";
txt_hex.Text = "";
txt_two.Text = "";
txt_eight.Text = "";
}
/*
* 进制转换开始 字符处理开始
* **/
private void btn_dao_Click(object sender, EventArgs e)/*倒序*/
{
try
{
string str = txt_qian.Text.Trim();
int i = str.Length;
string hou = "";
while (i > 0)
{
hou += str[i - 1].ToString();
i--;
}
txt_dao.Text = hou.ToString();
}
catch
{
MessageBox.Show("程序出错,请重新启动本程序,请注意检查输入的格式","程序出错");
}
}
private void btn_leftnuo_Click(object sender, EventArgs e)/*左挪*/
{
try
{
char[] ch = txt_chars.Text.ToCharArray();
int num = int.Parse(txt_num.Text);
char[] ch2 = new char[ch.Length];
string results = "";
for (int i = 0; i < ch.Length; i++)
{
if ((ch[i] >= 'a' && ch[i] <= 'z') || (ch[i] >= 'A' && ch[i] <= 'Z'))
{
ch2[i] += (char)(ch[i] - num);
if ((ch2[i] > 'Z' && ch2[i] <= 'Z' + 4) || ch2[i] > 'z')
{
ch2[i] = (char)(ch2[i] - 26 - num);
}
results += ch2[i].ToString();
}
else
{
ch2[i] += (char)(ch[i] - num);
results += ch2[i].ToString();
}
}
txt_results.Text = results.ToString();
}
catch
{
MessageBox.Show("输入的格式可能错误或本程序不支持", "温馨提示:");
}
}
private void btn_rightnuo_Click(object sender, EventArgs e)/*右挪*/
{
try
{
char[] ch = txt_chars.Text.ToCharArray();
int num = int.Parse(txt_num.Text);
char[] ch2 = new char[ch.Length];
string results = "";
for (int i = 0; i < ch.Length; i++)
{
if ((ch[i] >= 'a' && ch[i] <= 'z') || (ch[i] >= 'A' && ch[i] <= 'Z'))
{
ch2[i] += (char)(ch[i] + num);
if ((ch2[i] > 'Z' && ch2[i] <= 'Z' + 4) || ch2[i] > 'z')
{
ch2[i] = (char)(ch2[i] - 26 + num);
}
results += ch2[i].ToString();
}
else
{
ch2[i] += (char)(ch[i] + num);
results += ch2[i].ToString();
}
}
txt_results.Text = results.ToString();
}
catch
{
MessageBox.Show("输入的格式可能错误或本程序不支持", "温馨提示:");
}
}
private void btn_clearit_Click(object sender, EventArgs e)/*全部清空*/
{
txt_qian.Text = "";
txt_dao.Text = "";
txt_chars.Text = "";
txt_num.Text = "";
txt_results.Text = "";
}
/*
* 字符处理结束
* **/
}
}
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!