当前位置: 首页 > article >正文

Desfire Ev1\Ev2\Ev3卡DES\3K3DES\AES加解密读写C#示例源码

本示例使用的发卡器:https://item.taobao.com/item.htm?spm=a21dvs.23580594.0.0.1d292c1bYhsS9c&ft=t&id=917152255720 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;  //调用动态库一定要加入这个引用namespace MifareDesfireEv123
{public partial class Form1 : Form{//外部函数声明:让设备发出声响--------------------------------------------------------------------------------------------------------------------------[DllImport("OUR_MIFARE.dll", EntryPoint = "pcdbeep", CallingConvention = CallingConvention.StdCall)]static extern byte pcdbeep(Int32 xms);//xms单位为毫秒 //读取设备编号,可做为软件加密狗用,也可以根据此编号在公司网站上查询保修期限-----------------------------------------------------------------------------[DllImport("OUR_MIFARE.dll", EntryPoint = "pcdgetdevicenumber", CallingConvention = CallingConvention.StdCall)]static extern byte pcdgetdevicenumber(byte[] devicenumber);//devicenumber用于返回编号 //获取IC卡芯片型号---------------------------------------------------------------------------------------------------------------------------------------- [DllImport("OUR_MIFARE.dll", EntryPoint = "getmifareversion")]static extern byte getmifareversion(byte[] cardtypestr, byte[] AtqaSak, byte[] versionbuf, byte[] versionlen, byte[] retsw);//激活Desfire卡、CPU卡------------------------------------------------------------------------------------------------------------------------------------ [DllImport("OUR_MIFARE.dll", EntryPoint = "cpurequest1")]static extern byte cpurequest1(byte[] mypiccserial, byte[] myparam, byte[] myver, byte[] mycode, byte[] AtqaSak);//选择desfire卡 应用ID------------------------------------------------------------------------------------------------------------------------------------[DllImport("OUR_MIFARE.dll", EntryPoint = "desfireselectapplication")]static extern byte desfireselectapplication(byte[] aid, byte[] retsw);//EV1密钥认证---------------------------------------------------------------------------------------------------------------------------------------------[DllImport("OUR_MIFARE.dll", EntryPoint = "desfireauthkeyev1")]static extern byte desfireauthkeyev1(byte[] keybuf, byte keyid,byte authmode,byte[] retsw);//EV1更改密钥---------------------------------------------------------------------------------------------------------------------------------------------[DllImport("OUR_MIFARE.dll", EntryPoint = "desfirechangekeyev1")]static extern byte desfirechangekeyev1(byte[] newkeybuf, byte keyid, byte authmode, byte zeno, byte[] oldkeybuf, byte[] retsw);//EV2密钥认证---------------------------------------------------------------------------------------------------------------------------------------------[DllImport("OUR_MIFARE.dll", EntryPoint = "desfireauthkeyev2")]static extern byte desfireauthkeyev2(byte[] keybuf, byte keyid, byte authmode, byte[] retsw);//初始化卡(格式化卡) 返回 910E 时用-----------------------------------------------------------------------------------------------------------------------[DllImport("OUR_MIFARE.dll", EntryPoint = "desfireformatpicc")]static extern byte desfireformatpicc(byte[] retsw);//删除desfire卡内的应用AID------------------------------------------------------------------------------------------------------------------------------------[DllImport("OUR_MIFARE.dll", EntryPoint = "desfiredeleteapplication")]static extern byte desfiredeleteapplication(byte[] aid, byte[] retsw);//在desfire卡根目录下创建新应用AID-----------------------------------------------------------------------------------------------------------------------------[DllImport("OUR_MIFARE.dll", EntryPoint = "desfirecreateapplication")]static extern byte desfirecreateapplication(byte[] aid, byte keysetting,byte keynumver, byte keytype, byte[] retsw);//查询desfire卡内所有的应用AID-----------------------------------------------------------------------------------------------------------------------------[DllImport("OUR_MIFARE.dll", EntryPoint = "desfiregetapplicationids")]static extern byte desfiregetapplicationids(byte[] aidbuf, byte[] aidsize,  byte[] retsw);//获取AID应用的密钥配置信息-----------------------------------------------------------------------------------------------------------------------------[DllImport("OUR_MIFARE.dll", EntryPoint = "desfiregetkeysettings")]static extern byte desfiregetkeysettings(byte[] aidbuf, byte[] keysetting, byte[] keysize, byte[] retsw);//更改desfire卡内的应用的密钥配置信息-----------------------------------------------------------------------------------------------------------------------------[DllImport("OUR_MIFARE.dll", EntryPoint = "desfirechangekeysettings")]static extern byte desfirechangekeysettings(byte[] aidbuf, byte keysetting, byte[] retsw);//在desfire应用中创建标准文件------------------------------------------------------------------------------------------------------------------------------------[DllImport("OUR_MIFARE.dll", EntryPoint = "desfirecreatestddatafile")]static extern byte desfirecreatestddatafile(byte fileid, byte comset, byte[] accessrights, Int32  filesize, byte[] retsw);//在desfire应用中创建备份文件------------------------------------------------------------------------------------------------------------------------------------[DllImport("OUR_MIFARE.dll", EntryPoint = "desfircreatebackupdatafile")]static extern byte desfircreatebackupdatafile(byte fileid, byte comset, byte[] accessrights, Int32 filesize, byte[] retsw);//读取应用中的所有文件ID------------------------------------------------------------------------------------------------------------------------------[DllImport("OUR_MIFARE.dll", EntryPoint = "desfiregetfileids")]static extern byte desfiregetfileids(byte[] fileid, byte[] filessize,  byte[] retsw);//读取desfire卡应用中文件的配置信息------------------------------------------------------------------------------------------------------------------------------[DllImport("OUR_MIFARE.dll", EntryPoint = "desfiregetfilesettings")]static extern byte desfiregetfilesettings(byte fileid, byte[] filesettingsbuf, byte[] revbuflen, byte[] retsw);//更改desfire卡应用中文件的配置信息------------------------------------------------------------------------------------------------------------------------------[DllImport("OUR_MIFARE.dll", EntryPoint = "desfirechangefilesettings")]static extern byte desfirechangefilesettings(byte fileid, byte comset, byte[] accessrights,  byte[] retsw);//删除应用中的文件-----------------------------------------------------------------------------------------------------------------------------------------------[DllImport("OUR_MIFARE.dll", EntryPoint = "desfiredeletefile")]static extern byte desfiredeletefile(byte fileid, byte[] retsw);//读文件-----------------------------------------------------------------------------------------------------------------------------------------------[DllImport("OUR_MIFARE.dll", EntryPoint = "desfirereaddata")]static extern byte desfirereaddata(byte cmd, byte fileno, Int32 offset, Int32 datalen, byte[] databuf, byte[] retsw);//写文件-----------------------------------------------------------------------------------------------------------------------------------------------[DllImport("OUR_MIFARE.dll", EntryPoint = "desfirewritedata")]static extern byte desfirewritedata(byte cmd, byte fileno, Int32 offset, Int32 datalen, byte[] databuf, byte[] retsw);public Form1(){InitializeComponent();}//函数返回状态解析private static byte MessageDispInfo(byte errno){switch (errno){case 0:MessageBox.Show("操作成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);break;case 8:MessageBox.Show("请重新拿开卡后再放到感应区!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 23:MessageBox.Show("错误代码:" + errno.ToString("D") + ",驱动程序错误或尚未安装!", "示例提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 24:MessageBox.Show("错误代码:" + errno.ToString("D") + ",操作超时,一般是动态库没有反映!", "示例提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 25:MessageBox.Show("错误代码:" + errno.ToString("D") + ",发送字数不够!", "示例提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 26:MessageBox.Show("错误代码:" + errno.ToString("D") + ",发送的CRC错!", "示例提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 27:MessageBox.Show("错误代码:" + errno.ToString("D") + ",接收的字数不够!", "示例提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 28:MessageBox.Show("错误代码:" + errno.ToString("D") + ",接收的CRC错!", "示例提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 50:MessageBox.Show("RATS错误,厂家调试代码,用户不需理会!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 51:MessageBox.Show("PPS错误,厂家调试代码,用户不需理会!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 52:MessageBox.Show("已进入了14443-4协议状态,可进行CPU卡功能所有操作了!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 53:MessageBox.Show("CPU卡功能通讯错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 54:MessageBox.Show("数据不足,需要接着发送未完成的数据至卡上!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 55:MessageBox.Show("发送ACK指令给卡,让卡接着发送数据回来!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 56:MessageBox.Show("清空根目录失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 57:MessageBox.Show("卡片不支持功能!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 58:MessageBox.Show("卡片初始化失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 59:MessageBox.Show("分配的空间不足!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 60:MessageBox.Show("本次操作的实体已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 61:MessageBox.Show("无足够空间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 62:MessageBox.Show("文件不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 63:MessageBox.Show("权限不足,有可能是用只读密码认证,导致无法更改读写密码或无法写文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 64:MessageBox.Show("密码不存在,或密钥文件未创建!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 65:MessageBox.Show("传送长度错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 66:MessageBox.Show("Le错误,即接收的数据长度指定过大!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 67:MessageBox.Show("功能不支持或卡中无MF 或卡片已锁定!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 68:MessageBox.Show("密码认证错识次数过多,该密码已被锁死!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 86:MessageBox.Show("更改后的密码长度必须和创建时的长度一致!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 87:MessageBox.Show("应用目录不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 88:MessageBox.Show("应用文件不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 89:MessageBox.Show("文件号不能超过5!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 90:MessageBox.Show("读取文件时返回的长度不足,数据可能不正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 91:MessageBox.Show("一次读文件的长度不能超过255!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 92:MessageBox.Show("一次写文件的长度不能超过247!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;case 70:case 71:case 72:case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:case 81:case 82:case 83:case 84:case 85:MessageBox.Show("密码错误,剩余次数为" + Convert.ToString(errno - 70) + ",如果为0,该密码将锁死,无法再认证", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);break;default:MessageBox.Show("操作失败,返回错误代码!" + Convert.ToString(errno), "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);break;}return 0;}//判断16进制数据是否正确public static bool checkhexstr(string inputstr,int hexlen,byte[] bytebuf ) {try{inputstr = inputstr.Replace(" ", "");inputstr = inputstr.Replace("\r", "");inputstr = inputstr.Replace("\n", ""); for (int i=0;i<hexlen;i++){bytebuf[i] = Convert.ToByte(Convert.ToInt32(inputstr.Substring(i * 2, 2), 16));}return true;}catch{return false;}}//卡操作返回代码解析public static string RetTextFromStr(string inputstr){string RetTextFromStr = "";switch (inputstr){case "9000":RetTextFromStr = "成功!";break;case "9100":RetTextFromStr = "成功!";pcdbeep(20);break;case "6281":RetTextFromStr = "回送的数据可能错误!";break;case "6283":RetTextFromStr = "选择文件无效,文件或密钥校验错误";break;case "6400":RetTextFromStr = "状态标志未改变";break;case "6581":RetTextFromStr = "写 EEPROM 不成功!";break;case "6700":RetTextFromStr = "长度错误";break;case "6900":RetTextFromStr = "CLA 与线路保护要求不匹配";break;case "6901":RetTextFromStr = "无效的状态!";break;case "6981":RetTextFromStr = "命令与文件结构不相容";break;case "6982":RetTextFromStr = "不满足安全状态";break;case "6983":RetTextFromStr = "密钥被锁死!";break;case "6984":RetTextFromStr = "MAC格式不符合";break;case "6985":RetTextFromStr = "使用条件不满足";break;case "6986":RetTextFromStr = "请先选择文件!";break;case "6987":RetTextFromStr = "无安全报文";break;case "6988":RetTextFromStr = "安全报文数据项不正确";break;case "6A80":RetTextFromStr = "数据域参数错误!";break;case "6A81":RetTextFromStr = "功能不支持或卡中无MF 或卡片已锁定";break;case "6A82":RetTextFromStr = "文件未找到";break;case "6A83":RetTextFromStr = "记录未找到!";break;case "6A84":RetTextFromStr = "文件无足够空间";break;case "6A86":RetTextFromStr = "参数P1 P2 错";break;case "6A88":RetTextFromStr = "密钥未找到!";break;case "6B00":RetTextFromStr = "在达到Le/Lc 字节之前文件结束,偏移量错误";break;case "6E00":RetTextFromStr = "无效的CLA";break;case "6F00":RetTextFromStr = "数据无效!";break;case "9302":RetTextFromStr = "MAC 错误";break;case "9303":RetTextFromStr = "应用已被锁定";break;case "9401":RetTextFromStr = "金额不足!";break;case "9403":RetTextFromStr = "密钥未找到!";break;case "9406":RetTextFromStr = "所需的MAC 不可用!";break;case "91AE":RetTextFromStr = "认证失败,请检查命行的参数和前期计算是否错误!";break;case "91CA":RetTextFromStr = "上一个命令未完全完成!";break;case "917E":RetTextFromStr = "指令长度错误!";break;case "9140":RetTextFromStr = "当前目录或应用密钥不存在,请先选择正确的目录或应用!";break;case "919D":RetTextFromStr = "处于未验证密码的状态,该指令无法操作!";break;case "911E":RetTextFromStr = "MAC错误!";break;case "91F0":RetTextFromStr = "该文件号不存在!";break;case "919E":RetTextFromStr = "参数无效!";break;case "91BE":RetTextFromStr = "试图读取/写入的数据超出文件/记录的边界!";break;case "91A0":RetTextFromStr = "请求的 AID 不存在!";break;default:if (inputstr.Substring(0, 3) == "63C"){int i = Convert.ToInt16(inputstr.Substring(3, 1), 16);if(i>0){RetTextFromStr = "再试 "+i.ToString("D")+" 次错误密码将锁定!";}else { RetTextFromStr = "密码已被锁定"; }}else{RetTextFromStr="未知的异常";}break;} return RetTextFromStr;}private void Form1_Load(object sender, EventArgs e){comboBox1.SelectedIndex = 0;comboBox3.SelectedIndex = 0;comboBox14.SelectedIndex = 0;comboBox2.SelectedIndex = 0;comboBox4.SelectedIndex = 0;comboBox5.SelectedIndex = 1;comboBox6.SelectedIndex = 1;comboBox7.SelectedIndex = 1;comboBox8.SelectedIndex = 1;comboBox9.SelectedIndex = 0;comboBox10.SelectedIndex = 14;comboBox11.SelectedIndex = 14;comboBox12.SelectedIndex = 14;comboBox13.SelectedIndex = 14;}private void button1_Click(object sender, EventArgs e){byte status;  //'存放返回值byte[] mypiccserial = new byte[7];//'卡序列号            byte[] myparam = new byte[4];byte[] AtqaSak = new byte[3];byte[] myver = new byte[1];byte[] mycode = new byte[1];string cardhohex = "";string parastr = "";string verstr = "";string codestr = "";int i;status = cpurequest1(mypiccserial, myparam, myver, mycode, AtqaSak);if (status == 0 || status == 52){pcdbeep(20);if (AtqaSak[0] / 64 > 0){for (i = 0; i < 7; i++) { cardhohex = cardhohex + mypiccserial[i].ToString("X2"); }for (i = 0; i < 4; i++) { parastr = parastr + myparam[i].ToString("X2"); }verstr = myver[0].ToString("X2");codestr = mycode[0].ToString("X2");textBox1.Text = cardhohex;MessageBox.Show("激活Desfire卡成功,可以接着重复操作第二步进行调试了。\r\n" + "16进制卡号:" + cardhohex + "\r\n参数:" + parastr + "\r\n版本信息:" + verstr + "\r\n厂商代码(复旦为90):" + codestr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}else{for (i = 0; i < 4; i++) { cardhohex = cardhohex + mypiccserial[i].ToString("X2"); }for (i = 0; i < 4; i++) { parastr = parastr + myparam[i].ToString("X2"); }verstr = myver[0].ToString("X2");codestr = mycode[0].ToString("X2");textBox1.Text = cardhohex;MessageBox.Show("激活Fm1208CPU卡成功,可以接着重复操作第二步进行调试了。\r\n" + "16进制卡号:" + cardhohex + "\r\n参数:" + parastr + "\r\n版本信息:" + verstr + "\r\n厂商代码(复旦为90):" + codestr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}}else{MessageDispInfo(status);}}private void button2_Click(object sender, EventArgs e){byte[] aidbuf =new byte[3];byte[] retsw = new byte[2];string retstr;if (checkhexstr(textBox2.Text.Trim(),3 ,aidbuf)==false) {MessageBox.Show("十六进制AID输入错误,请输入3字节的16进制AID!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}byte status = desfireselectapplication(aidbuf, retsw);retstr = retsw[0].ToString("X2") + retsw[1].ToString("X2");if (status > 0){MessageBox.Show("选择卡内应用AID操作返回异常:" + status.ToString("D") + ",卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);}else{MessageBox.Show("选择卡内应用AID操作卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}}private void button4_Click(object sender, EventArgs e){byte status = pcdbeep(50);if (status != 0){MessageDispInfo(status);}}private void button8_Click(object sender, EventArgs e){byte[] devno = new byte[4];byte status = pcdgetdevicenumber(devno);if (status == 0){pcdbeep(50);MessageBox.Show("设备的序列号为:" + devno[0].ToString("D3") + "-" + devno[1].ToString("D3") + "-" + devno[2].ToString("D3") + "-" + devno[3].ToString("D3"), "示例程序", MessageBoxButtons.OK, MessageBoxIcon.Information);}else { MessageDispInfo(status); }}private void button3_Click(object sender, EventArgs e){byte[] authkeybuf = new byte[24];byte[] retsw = new byte[2];string retstr;int keylen;switch (comboBox1.SelectedIndex){case 0:keylen=8;break;case 1:keylen = 16;break;case 2:keylen = 24;break;default :keylen = 16;break;}if (checkhexstr(textBox3.Text.Trim(), keylen, authkeybuf) == false){MessageBox.Show("十六进制认证密钥输入错误,请输入 "+keylen.ToString("D")+  " 字节的16进制认证密钥!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}byte status = desfireauthkeyev1(authkeybuf, Convert.ToByte(keyid.Value), Convert.ToByte(comboBox1.SelectedIndex), retsw);retstr = retsw[0].ToString("X2") + retsw[1].ToString("X2");if (status > 0){MessageBox.Show("认证密码操作返回异常:" + status.ToString("D") + ",卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);}else{MessageBox.Show("认证密码操作,卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}}private void comboBox1_SelectedIndexChanged(object sender, EventArgs e){switch (comboBox1.SelectedIndex){case 0:textBox3.Text = "00 00 00 00 00 00 00 00";break;case 1:textBox3.Text = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";break;case 2:textBox3.Text = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";break;default :textBox3.Text = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";break;}}private void comboBox3_SelectedIndexChanged(object sender, EventArgs e){switch (comboBox3.SelectedIndex){case 0:textBox3.Text = "00 00 00 00 00 00 00 00";textBox4.Text = "00 00 00 00 00 00 00 00";break;case 1:textBox3.Text = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";textBox4.Text = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";break;case 2:textBox3.Text = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";textBox4.Text = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";break;default :textBox3.Text = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";textBox4.Text = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";break;}}private void button6_Click(object sender, EventArgs e){byte[] newkeybuf = new byte[24];byte[] oldkeybuf = new byte[24];byte[] retsw = new byte[2];string retstr;int keylen;switch (comboBox3.SelectedIndex){case 0:keylen = 8;break;case 1:keylen = 16;break;case 2:keylen = 24;break;default:keylen = 16;break;}if (checkhexstr(textBox4.Text.Trim(), keylen, newkeybuf) == false){MessageBox.Show("十六进制新密钥输入错误,请输入 " + keylen.ToString("D") + " 字节的16进制新密钥!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}if (checkhexstr(textBox3.Text.Trim(), keylen, oldkeybuf) == false){MessageBox.Show("十六进制旧密钥输入错误,请输入 " + keylen.ToString("D") + " 字节的16进制旧密钥!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}byte status = desfirechangekeyev1(newkeybuf, Convert.ToByte(keyid.Value), Convert.ToByte(comboBox3.SelectedIndex),0,oldkeybuf, retsw);retstr = retsw[0].ToString("X2") + retsw[1].ToString("X2");if (status > 0){MessageBox.Show("EV1更改密码操作返回异常:" + status.ToString("D") + ",卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);}else{MessageBox.Show("EV1更改密码操作,卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}}private void button5_Click(object sender, EventArgs e){byte[] retsw = new byte[2];string retstr;byte status = desfireformatpicc(retsw);retstr = retsw[0].ToString("X2") + retsw[1].ToString("X2");if (status > 0){MessageBox.Show("初始格式化卡操作返回异常:" + status.ToString("D") + ",卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);}else{MessageBox.Show("初始格式化卡操作,卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}}private void button7_Click(object sender, EventArgs e){byte[] AtqaSak = new byte[3];byte[] retsw = new byte[2];byte[] versionbuf = new byte[100];byte[] versionlen = new byte[2];byte[] cardtypebuf = new byte[1024];byte status = getmifareversion(cardtypebuf, AtqaSak, versionbuf, versionlen, retsw);string cardtypestr = Encoding.ASCII.GetString(cardtypebuf).Trim() ;string retstr = retsw[0].ToString("X2") + retsw[1].ToString("X2");if (status > 0){MessageDispInfo(status);}else{MessageBox.Show("获取IC卡芯片型号操作,卡片返回代码:" + retstr + "\r\n型号:" + cardtypestr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}}private void button10_Click(object sender, EventArgs e){byte[] aidbuf = new byte[3];byte[] retsw = new byte[2];string retstr;if (checkhexstr(textBox5.Text.Trim(), 3, aidbuf) == false){MessageBox.Show("十六进制AID输入错误,请输入3字节的16进制AID!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}byte status = desfiredeleteapplication(aidbuf, retsw);retstr = retsw[0].ToString("X2") + retsw[1].ToString("X2");if (status > 0){MessageBox.Show("删除卡内应用操作返回异常:" + status.ToString("D") + ",卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);}else{MessageBox.Show("删除卡内应用操作卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}}private void button9_Click(object sender, EventArgs e){byte[] aidbuf = new byte[3];byte[] retsw = new byte[2];string retstr;if (checkhexstr(textBox5.Text.Trim(), 3, aidbuf) == false){MessageBox.Show("十六进制AID输入错误,请输入3字节的16进制AID!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}byte keysetting =Convert.ToByte ( comboBox4.SelectedIndex * 16+comboBox5.SelectedIndex * 8+comboBox6.SelectedIndex * 4+comboBox7.SelectedIndex * 2+comboBox8.SelectedIndex );byte status = desfirecreateapplication(aidbuf, keysetting,Convert.ToByte(keynumber.Value),Convert.ToByte(comboBox2.SelectedIndex), retsw);retstr = retsw[0].ToString("X2") + retsw[1].ToString("X2");if (status > 0){MessageBox.Show("创建新应用操作返回异常:" + status.ToString("D") + ",卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);}else{MessageBox.Show("创建新应用操作卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}}private void button11_Click(object sender, EventArgs e){byte status;        //函数返回值byte comset;        //通讯模式byte[] accessrights = new byte[2];   //文件访问时的密钥认证方式byte[] retsw = new byte[2];          //卡片返回值            string retstr;Int32 filebytes = Convert.ToInt32(filesize.Value);if (comboBox9.SelectedIndex < 2){comset =Convert.ToByte (comboBox9.SelectedIndex);}else { comset = 3; }accessrights[1] =Convert.ToByte(comboBox10.SelectedIndex * 16 + comboBox11.SelectedIndex);accessrights[0] = Convert.ToByte(comboBox12.SelectedIndex * 16 + comboBox13.SelectedIndex);if (radioButton1.Checked){status = desfirecreatestddatafile(Convert.ToByte(fileid.Value), comset, accessrights, filebytes, retsw);}else{               status = desfircreatebackupdatafile(Convert.ToByte(fileid.Value), comset, accessrights, filebytes, retsw);}retstr = retsw[0].ToString("X2") + retsw[1].ToString("X2");if (status == 53){MessageBox.Show("在应用内创建新文件操作返回异常:" + status.ToString("D") + ",说明:CPU卡功能通讯错误,可能是卡拿开重放后未激活或卡不在感应区!" , "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}else{if (status == 64){if (retstr == "91DE"){MessageBox.Show("在应用内创建新文件操作返回异常:" + status.ToString("D") + ",卡片返回代码:" + retstr + ",可能的原因:1 应用没选择对,2 密码未认证,3 文件已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}else{MessageBox.Show("在应用内创建新文件操作返回异常:" + status.ToString("D") + ",卡片返回代码:" + retstr + ",请选择正确的应用!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}}else{if (status > 0){MessageBox.Show("在应用内创建新文件操作返回异常:" + status.ToString("D") + ",卡片返回代码:" + retstr + ",说明:"+RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}}}MessageBox.Show("在应用内创建新文件操作卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}private void button12_Click(object sender, EventArgs e){byte[] revbuflen=new byte[4];byte[] filesettingsbuf=new byte[32];byte[] retsw = new byte[2];          //卡片返回值            string retstr;string revstr = "";byte status = desfiregetfilesettings(Convert.ToByte(fileid.Value), filesettingsbuf, revbuflen, retsw);retstr = retsw[0].ToString("X2") + retsw[1].ToString("X2");if (status > 0){MessageBox.Show("读取文件配置信息返回异常:" + status.ToString("D") + ",卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}Int32  revlen = BitConverter.ToInt32(revbuflen, 0);for (Int32 j = 0; j < revlen;j++ ){revstr = revstr + filesettingsbuf[j].ToString("X2");}if (filesettingsbuf[1] % 4 == 3) {                 //解析通信模式comboBox9.SelectedIndex = 2;} else{if (filesettingsbuf[1] % 4 == 1){comboBox9.SelectedIndex = 1;}else{comboBox9.SelectedIndex = 0;}}comboBox10.SelectedIndex = filesettingsbuf[3] / 16;   //只读时需要的密码号comboBox11.SelectedIndex = filesettingsbuf[3] % 16;   //只写时需要的密码号comboBox12.SelectedIndex = filesettingsbuf[2] / 16;   //读写时需要的密码号comboBox13.SelectedIndex = filesettingsbuf[2] % 16;   //更改本配置时需要的密码号filesize.Value = filesettingsbuf[4] + filesettingsbuf[5] * 256 + filesettingsbuf[6] * 65536;  MessageBox.Show("读取文件配置返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr) + ",16进制文件配置信息:" + revstr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}private void button14_Click(object sender, EventArgs e){byte[] retsw = new byte[2];          //卡片返回值            string retstr;byte status = desfiredeletefile(Convert.ToByte(fileid.Value), retsw);retstr = retsw[0].ToString("X2") + retsw[1].ToString("X2");if (status > 0){MessageBox.Show("删除文件操作返回异常:" + status.ToString("D") + ",卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);}else{MessageBox.Show("删除文件操作卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr) , "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}}private void button15_Click(object sender, EventArgs e){byte cmd = 0xBD;                  //函数第1个参数为&HBD表示读数据,为&hBB表示读记录byte[] databuf = new byte[8192];byte[] retsw = new byte[2];       //卡片返回值            string retstr;byte status = desfirereaddata(cmd, Convert.ToByte(fileid.Value), Convert.ToInt32(rwbegin.Value), Convert.ToInt32(rwlen.Value), databuf, retsw);retstr = retsw[0].ToString("X2") + retsw[1].ToString("X2");if (status == 63){MessageBox.Show("读文件操作返回异常:" + status.ToString("D") + ",说明:权限不足,请先用正确的密钥号认证!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}else{if (status > 0){MessageBox.Show("读文件操作返回异常:" + status.ToString("D") + ",卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}else{string datastr = "";for (Int32 j = 0; j < Convert.ToInt32(rwlen.Value); j++){datastr = datastr + databuf[j].ToString("X2") + " ";}textBox8.Text = datastr;MessageBox.Show("读文件操作卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}}}private void button17_Click(object sender, EventArgs e){Int32 i = 0;string datastr = "";for (Int32 j = 0; j < Convert.ToInt32(rwlen.Value); j++){datastr = datastr + i.ToString("X2") + " ";i++;if (i == 256) { i = 0; }}textBox8.Text = datastr;}private void button16_Click(object sender, EventArgs e){byte cmd = 0x3D;                  //函数第1个参数为&H3D表示写数据,为&h3B表示写记录byte[] databuf = new byte[8192];byte[] retsw = new byte[2];       //卡片返回值            string retstr;if (checkhexstr(textBox8.Text.Trim(), Convert.ToInt32(rwlen.Value), databuf) == false){if (MessageBox.Show("写入数据输入不足或错误,是否要生成写入数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes ){button17.PerformClick();}return;}byte status = desfirewritedata(cmd, Convert.ToByte(fileid.Value), Convert.ToInt32(rwbegin.Value), Convert.ToInt32(rwlen.Value), databuf, retsw);retstr = retsw[0].ToString("X2") + retsw[1].ToString("X2");if (status == 63){MessageBox.Show("写文件操作返回异常:" + status.ToString("D") + ",说明:权限不足,请先用正确的密钥号认证!" , "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}else{if (status > 0){MessageBox.Show("写文件操作返回异常:" + status.ToString("D") + ",卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}else{MessageBox.Show("写文件操作卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}}}private void button18_Click(object sender, EventArgs e){byte[] authkeybuf = new byte[24];byte[] retsw = new byte[2];string retstr;int keylen=16;if (checkhexstr(textBox6.Text.Trim(), keylen, authkeybuf) == false){MessageBox.Show("十六进制认证密钥输入错误,请输入 " + keylen.ToString("D") + " 字节的16进制认证密钥!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}byte status = desfireauthkeyev2(authkeybuf, Convert.ToByte(keyid.Value), Convert.ToByte(comboBox14.SelectedIndex), retsw);retstr = retsw[0].ToString("X2") + retsw[1].ToString("X2");if (status > 0){MessageBox.Show("认证密码操作返回异常:" + status.ToString("D") + ",卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);}else{MessageBox.Show("认证密码操作,卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}}private void Button20_Click(object sender, EventArgs e){byte[] retsw = new byte[2];byte[] aidsize = new byte[1];       //返回的应用数量,最大19个byte[] aidbuf = new byte[57];       //应用AID号数据缓冲,每个AID号占用3个字节,最多19个应AID号byte status = desfiregetapplicationids(aidbuf, aidsize, retsw);string retstr = retsw[0].ToString("X2") + retsw[1].ToString("X2");if (status > 0) {MessageBox.Show("搜索当前卡片内所有应用AID操作返回异常:" + status.ToString("D") + ",卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}string strls1="";if (aidsize[0] > 0){strls1 = "应用AID:" + aidbuf[0].ToString("X2") + aidbuf[1].ToString("X2")+ aidbuf[2].ToString("X2");byte j=1;while (j<aidsize[0]){strls1 = strls1 + "," + aidbuf[j * 3].ToString("X2") + aidbuf[j * 3 + 1].ToString("X2") + aidbuf[j * 3 + 2].ToString("X2");j++;}            }MessageBox.Show("搜索当前卡片内所有应用AID操作,卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr)  + "\r\n应用数量:" + aidsize[0].ToString("D") +"\r\n" + strls1, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}private void Button21_Click(object sender, EventArgs e){byte[] aidbuf = new byte[3];byte[] keysetting = new byte[1];byte[] keysize = new byte[1];byte[] retsw = new byte[2];if (checkhexstr(textBox5.Text.Trim(), 3, aidbuf) == false){MessageBox.Show("十六进制AID输入错误,请输入3字节的16进制AID!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}byte status = desfiregetkeysettings(aidbuf, keysetting, keysize, retsw);string retstr = retsw[0].ToString("X2") + retsw[1].ToString("X2");if (status == 94){MessageBox.Show("请先执行选择应用AID:" + textBox5.Text.Trim(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}else{if (status > 0){MessageBox.Show("读取应用的配置信息操作返回异常:" + status.ToString("D") + ",卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}}comboBox4.SelectedIndex = keysetting[0] / 16;  //更改应用密钥(非应用主密钥) 需要验证的选项if ((keysetting[0] & 8)>0){comboBox5.SelectedIndex = 1;}else{comboBox5.SelectedIndex = 0;}if ((keysetting[0] & 4)>0){comboBox6.SelectedIndex = 1;}else{comboBox6.SelectedIndex = 0;}if ((keysetting[0] & 2) > 0){comboBox7.SelectedIndex = 1;}else {comboBox7.SelectedIndex = 0;}if ((keysetting[0] & 1) > 0) {comboBox8.SelectedIndex = 1;}else {comboBox8.SelectedIndex = 0;}int keynum = keysize[0] % 64 ;keynumber.Value = keynum;if ((keysize[0] & 0xc0) == 0x80){comboBox2.SelectedIndex = 3;}else{if ((keysize[0] & 0xc0) == 0x40){comboBox2.SelectedIndex = 2;}else{comboBox2.SelectedIndex = 0;        //也可能是comboBox2.SelectedIndex = 1}}MessageBox.Show("读取应用的密钥配置信息操作,卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr)  + "\r\n密钥配置:" + keysetting[0].ToString("X2")  + "\r\n密钥数量:" + keynum.ToString("D"), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}private void Button22_Click(object sender, EventArgs e){byte[] aidbuf = new byte[3];byte[] retsw = new byte[2];string retstr;if (checkhexstr(textBox5.Text.Trim(), 3, aidbuf) == false){MessageBox.Show("十六进制AID输入错误,请输入3字节的16进制AID!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}byte keysetting = Convert.ToByte(comboBox4.SelectedIndex * 16 + comboBox5.SelectedIndex * 8 + comboBox6.SelectedIndex * 4 + comboBox7.SelectedIndex * 2 + comboBox8.SelectedIndex);byte status = desfirechangekeysettings(aidbuf, keysetting,  retsw);retstr = retsw[0].ToString("X2") + retsw[1].ToString("X2");if (status == 94){MessageBox.Show("请先执行选择应用AID:" + textBox5.Text.Trim(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}else{if (status == 63){MessageBox.Show("需要先验证当前应用的主密钥!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}else{if (status > 0){MessageBox.Show("更改应用密钥配置操作返回异常:" + status.ToString("D") + ",卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}                    }}MessageBox.Show("更改应用密钥配置操作,卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}private void Button19_Click(object sender, EventArgs e){byte[] retsw = new byte[2];byte[] fidsize = new byte[1];       //返回的文件数量,最大19个byte[] fidbuf = new byte[16];       //文件ID号数据缓冲,每个ID号占用1个字节,最多16个文件ID号byte status = desfiregetfileids(fidbuf, fidsize, retsw);string retstr = retsw[0].ToString("X2") + retsw[1].ToString("X2");if (status > 0){MessageBox.Show("搜索当前应用内所有文件ID操作返回异常:" + status.ToString("D") + ",卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}string strls1 = "";if (fidsize[0] > 0){strls1 = "文件ID:" + fidbuf[0].ToString("D") ;byte j = 1;while (j < fidsize[0]){strls1 = strls1 + "," + fidbuf[j ].ToString("D") ;j++;}}MessageBox.Show("搜索当前应用内所有文件ID操作,卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr) + "\r\n文件数量:" + fidsize[0].ToString("D") + "\r\n" + strls1, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}private void button13_Click(object sender, EventArgs e){byte status;        //函数返回值byte comset;        //通讯模式byte[] accessrights = new byte[2];   //文件访问时的密钥认证方式byte[] retsw = new byte[2];          //卡片返回值            if (comboBox9.SelectedIndex < 2){comset = Convert.ToByte(comboBox9.SelectedIndex);}else { comset = 3; }accessrights[1] = Convert.ToByte(comboBox10.SelectedIndex * 16 + comboBox11.SelectedIndex);accessrights[0] = Convert.ToByte(comboBox12.SelectedIndex * 16 + comboBox13.SelectedIndex);status = desfirechangefilesettings(Convert.ToByte(fileid.Value), comset, accessrights, retsw);string retstr = retsw[0].ToString("X2") + retsw[1].ToString("X2");if (status == 53){MessageBox.Show("更改文件配置操作返回异常:" + status.ToString("D") + ",说明:CPU卡功能通讯错误,可能是卡拿开重放后未激活或卡不在感应区!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}else{if (status > 0){MessageBox.Show("更改文件配置操作返回异常:" + status.ToString("D") + ",卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);return;}}MessageBox.Show("更改文件配置操作卡片返回代码:" + retstr + ",说明:" + RetTextFromStr(retstr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}}
}

相关文章:

Desfire Ev1\Ev2\Ev3卡DES\3K3DES\AES加解密读写C#示例源码

本示例使用的发卡器&#xff1a;https://item.taobao.com/item.htm?spma21dvs.23580594.0.0.1d292c1bYhsS9c&ftt&id917152255720 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using S…...

MySQL核心内容【完结】

MySQL核心内容 文章目录 MySQL核心内容1.MySQL核心内容目录2.MySQL知识面扩展3.MySQL安装4.MySQL配置目录介绍Mysql配置远程ip连接 5.MySQL基础1.MySQL数据类型1.数值类型2.字符串类型3.日期和时间类型4.enum和set 2.MySQL运算符1.算数运算符2.逻辑运算符3.比较运算符 3.MySQL完…...

C++类和对象进阶 —— 与数据结构的结合

&#x1f381;个人主页&#xff1a;工藤新一 &#x1f50d;系列专栏&#xff1a;C面向对象&#xff08;类和对象篇&#xff09; &#x1f31f;心中的天空之城&#xff0c;终会照亮我前方的路 &#x1f389;欢迎大家点赞&#x1f44d;评论&#x1f4dd;收藏⭐文章 文章目录 […...

Django之账号登录及权限管理

账号登录及权限管理 目录 1.登录功能 2.退出登录 3.权限管理 4.代码展示合集 这篇文章, 会讲到如何实现账号登录。账号就是我们上一篇文章写的账号管理功能, 就使用那里面已经创建好的账号。这一次登录, 我们分为三种角色, 分别是员工, 领导, 管理员。不同的角色, 登录进去…...

从一城一云到AI CITY,智慧城市进入新阶段

AI将如何改变城市面貌&#xff1f;AI能否为城市创造新的商业价值&#xff1f;AI的落地应用将对日常生活有什么样的影响&#xff1f; 几乎在每一场和城市发展相关的论坛上&#xff0c;都会出现以上几个问题。城市既是AI技术创新融合应用的综合性载体&#xff0c;普罗大众对AI产…...

Oracle数据库DBF文件收缩

这两天新部署了一套系统&#xff0c;数据库结构保持不变&#xff0c;牵扯导出表结构还有函数&#xff0c;图省事就直接新建用户&#xff0c;还原数据库了。然后咔咔咔&#xff0c;一顿删除delete&#xff0c;truncate&#xff0c;发现要不就是表删了&#xff0c;还有num_rows&a…...

EXCEL中嵌入其他表格等文件

在EXCEL中嵌入其他表格 先放链接&#xff1a;https://jingyan.baidu.com/article/295430f11708c34d7e00509a.html 步骤如下&#xff1a; 1、打开一个需要嵌入新表格的excel表。 2、切换至“插入”菜单中&#xff0c;单击选择“对象”。 3、如下图所示&#xff0c;会弹出“对象…...

21. LangChain金融领域:合同审查与风险预警自动化

引言&#xff1a;当AI成为24小时不眠的法律顾问 2025年某商业银行的智能合同系统&#xff0c;将百万级合同审查时间从平均3周缩短至9分钟&#xff0c;风险条款识别准确率达98.7%。本文将基于LangChain的金融法律框架&#xff0c;详解如何构建合规、精准、可追溯的智能风控体系…...

Springboot使用事件流调用大模型接口

什么是事件流 事件流&#xff08;Event Stream&#xff09; 是一种处理和传递事件的方式&#xff0c;通常用于系统中的异步消息传递或实时数据流。在事件驱动架构&#xff08;Event-Driven Architecture&#xff09;中&#xff0c;事件流扮演着至关重要的角色。 事件流的概念…...

计算机网络--2

TCP三次握手 TCP连接为什么需要三次握手 1. 由于网络情况复杂,可能会出现丢包现象,如果第二次握手的时候服务器就认为这个端口可用,然后一直开启,但是如果客户端未收到服务器发送的回复,那么就会重新发送请求,服务器就会重新开启一个端口连接,这样就会浪费一个端口。 三…...

【已解决】WORD域相关问题;错误 未找到引用源;复制域出错;交叉引用域到底是个啥

&#xff08;微软赶紧倒闭 所有交叉引用域&#xff0c;有两个状态&#xff1a;1.锁定。2.手动。可通过编辑->链接查看。 “锁定”状态域的能力&#xff1a; 1. 导出PDF格式稳定&#xff08;【已解决】WORD导出PDF时&#xff0c;参考文献上标自动被取消/变为正常文本_word…...

尤雨溪宣布:Vue 生态正式引入 AI

在前端开发领域,Vue 框架一直以其易用性和灵活性受到广大开发者的喜爱。 而如今,Vue 生态在人工智能(AI)领域的应用上又迈出了重要的一步。 尤雨溪近日宣布,Vue、Vite 和 Rolldown 的文档网站均已添加了llms.txt文件,这一举措旨在让大型语言模型(LLM)更方便地理解这些…...

蓝桥杯第十六届c组c++题目及个人理解

本篇文章只是部分题目的理解&#xff0c;代码和思路仅供参考&#xff0c;切勿当成正确答案&#xff0c;欢迎各位小伙伴在评论区与博主交流&#xff01; 题目&#xff1a;2025 题目解析 核心提取 要求的数中至少有1个0、2个2、1个5 代码展示 #include<iostream> #incl…...

【MVCP】基于解纠缠表示学习和跨模态-上下文关联挖掘的多模态情感分析

多处可看出与同专栏下的DCCMCI很像 abstract 多模态情感分析旨在从多模态数据中提取用户表达的情感信息,包括语言、声学和视觉线索。 然而,多模态数据的异质性导致了模态分布的差异,从而影响了模型有效整合多模态互补性和冗余性的能力。此外,现有的方法通常在获得表征后直…...

Go语言--语法基础4--基本数据类型--类型转换

Go 编程语言中 if 条件语句的语法如下&#xff1a; 1 、基本形式 if 布尔表达式 { /* 在布尔表达式为 true 时执行 */ } If 在布尔表达式为 true 时&#xff0c;其后紧跟的语句块执行&#xff0c;如果为 false 则 不执行。 package main import "fmt"…...

硬件工程师笔记——电子器件汇总大全

目录 1、电阻 工作原理 欧姆定律 电阻的物理本质 一、限制电流 二、分压作用 三、消耗电能&#xff08;将电能转化为热能&#xff09; 2、压敏电阻 伏安特性 1. 过压保护 2. 电压调节 3. 浪涌吸收 4. 消噪与消火花 5. 高频应用 3、电容 工作原理 &#xff08;…...

微软推动智能体协同运作:支持 A2A、MCP 协议

今日凌晨&#xff0c;微软宣布 Azure AI Foundry 和 Microsoft Copilot Studio 两大开发平台支持最新 Agent 开发协议 A2A&#xff0c;并与谷歌合作开发扩大该协议&#xff0c;这一举措对智能体赛道意义重大。 现状与变革意义 当前智能体领域类似战国时代&#xff0c;各家技术…...

Qt模块化架构设计教程 -- 轻松上手插件开发

概述 在软件开发领域,随着项目的增长和需求的变化,保持代码的可维护性和扩展性变得尤为重要。一个有效的解决方案是采用模块化架构,尤其是利用插件系统来增强应用的功能性和灵活性。Qt框架提供了一套强大的插件机制,可以帮助开发者轻松实现这种架构。 模块化与插件系统 模…...

Linxu实验五——NFS服务器

一.NFS服务器介绍 NFS服务器&#xff08;Network File System&#xff09;是一种基于网络的分布式文件系统协议&#xff0c;允许不同操作系统的主机通过网络共享文件和目录3。其核心作用在于实现跨平台的资源透明访问&#xff0c;例如在Linux和Unix系统之间共享静态数据&#…...

RV1126 ROS2环境交叉编译及部署(基于官方Docker)

RV1126 ROS2环境交叉编译及部署(基于官方Docker) 0 前言1 SDK源码更新1.1 启动Docker容器1.2 更新SDK源码1.3 SDK更新问题2 ROS2编译配置3 Buildroot rootfs编译ROS2的依赖包3.1 编译问题解决4 使用Docker交叉编译ROS24.1 准备Linux(Ubuntu) PC机的依赖环境4.1.1 Ubuntu PC机…...

20242817李臻《Linux⾼级编程实践》第9周

20242817李臻《Linux⾼级编程实践》第9周 一、AI对学习内容的总结 第十章 Linux下的数据库编程 10.1 MySQL数据库简介 MySQL概述&#xff1a;MySQL是一个开源的关系型数据库管理系统&#xff0c;最初由瑞典MySQL AB公司开发&#xff0c;后经SUN公司收购&#xff0c;现属于O…...

查看YOLO版本的三种方法

查看YOLO版本的三种方法&#xff1a; 一、通过命令行直接查询 使用Python交互式查询&#xff1a; from ultralytics import __version__ print(__version__) # 示例输出: 11.0.5二、检查PyTorch环境兼容性 import torch, ultralytics print(f"PyTorch: {torch.__versi…...

双流 JOIN 与维表 JOIN 的区别

Flink 双流 JOIN 与维表 JOIN 的区别 1. 数据关联的实时性与更新机制 维表 JOIN 基于当前快照 关联外部存储&#xff08;如 MySQL、HBase&#xff09;的 最新状态&#xff0c;仅反映处理时间的当前数据&#xff0c;历史结果不会随维表更新而修正。无状态回溯 无法关联历史版…...

MySQL OCP和Oracle OCP怎么选?

近期oracle 为庆祝 MySQL 数据库发布 30 周年&#xff0c;Oracle 官方推出限时福利&#xff1a;2025 年 4 月 20 日至 7 月 31 日期间&#xff0c;所有人均可免费报考 MySQL OCP&#xff08;Oracle Certified Professional&#xff09;认证考试&#xff08;具体可查看MySQL OCP…...

汽车为什么需要以太网?带宽?实时?

一、传统总线“堵车”&#xff1a;为什么CAN、LIN扛不住了&#xff1f; 1. 带宽危机 案例&#xff1a;一辆L3级自动驾驶汽车每秒产生约4GB数据&#xff08;激光雷达摄像头&#xff09;&#xff0c;而CAN FD总线最高仅8Mbps。若用CAN传输&#xff0c;需 500秒才能传完1秒的数据—…...

开源分享:TTS-Web-Vue系列:SSML格式化功能与高级语音合成

&#x1f3af; 本文是TTS-Web-Vue系列的第十二篇文章&#xff0c;重点介绍项目新增的SSML格式化功能以及SSML在语音合成中的应用。通过自动格式化和实时预览&#xff0c;我们显著提升了SSML编辑体验&#xff0c;让用户能够更精确地控制语音合成的细节&#xff0c;实现更自然、更…...

[人机交互]理解界面对用户的影响

零.重点 – 什么是情感因素 – 富有表现力的界面 – 用户的挫败感 – 拟人化在交互设计中的应用 – 虚拟人物&#xff1a;代理 一.什么是情感方面 情感是指某事物对心理造成的一种状态 二.计算机科学中存在的两个相关的研究领域 2.1情感计算 机器如何能感知其他代理的情感&…...

FAST-LIO笔记

1.FAST-LIO FAST-LIO 是一个计算效率高、鲁棒性强的激光-惯性里程计系统。该系统通过紧耦合的迭代扩展卡尔曼滤波器&#xff08;IEKF&#xff09;将激光雷达特征点与IMU数据进行融合&#xff0c;使其在快速运动、噪声较大或环境复杂、存在退化的情况下仍能实现稳定的导航。 1…...

软考中级软件设计师——UML(统一建模语言)篇

UML的词汇表包含3种构造块:事物、关系和图。事物是对模型中最具有代表性的成分的抽象;关系把事物结合在一起;图聚集了相关的事物。 一、事物 UML 事物是模型中的基本元素&#xff0c;分为 结构事物、行为事物、分组事物、注释事物。 1. 结构事物 类&#xff08;Class&#x…...

TSN网络与DIOS融合:破解煤矿井下电力系统越级跳闸难题

一、引言 1.1 研究背景与意义 在现代煤矿生产中&#xff0c;井下电力系统作为整个煤矿生产的动力核心&#xff0c;其重要性不言而喻。煤矿井下的各类机械设备&#xff0c;如采煤机、刮板输送机、通风机、排水泵等&#xff0c;都依赖稳定的电力供应才能正常运行。电力系统的稳定…...