//加密 private DataInfo encryp(ParamsList param) { EncrypList encrypList = new EncrypList(); encrypList.Encryp = new List <string>(); foreach (string str in param.paramsString) { if (str != "" && str != null) { string s = RUtils.Encrypt(bKey, str); encrypList.Encryp.Add(s); } else { encrypList.Encryp.Add(""); } } DataInfo datainfo = new DataInfo(); datainfo.Code = 0; datainfo.Data = encrypList; return(datainfo); }
//解密 private DataInfo decrypt(DecryptParamsList param) { DecryptList decryptInfo = new DecryptList(); decryptInfo.Decrypt = param.paramsString; Parallel.For(0, decryptInfo.Decrypt.Count, (i) => { List <string> strs = decryptInfo.Decrypt[(int)i]; Parallel.For(0, strs.Count, (j) => { string str = strs[(int)j]; if (str != "" && str != null) { if (ht[str] == null) { string dStr = RUtils.Decrypt(bKey, str); decryptInfo.Decrypt[(int)i][(int)j] = dStr; ht[str] = dStr; } else { decryptInfo.Decrypt[(int)i][(int)j] = (string)ht[str]; } } else { decryptInfo.Decrypt[(int)i][(int)j] = ""; } }); }); DataInfo datainfo = new DataInfo(); datainfo.Code = 0; datainfo.Data = decryptInfo; return(datainfo); }
private DataInfo getDogInfo() { uint uiVer = 0; //版本号 uint uiAgent = 0; //代理编号 uint uiPID = 0; //产品ID uint uiUID = 0; //用户ID uint uiDevType = 0; //设备类型 uint uiIsMother = 0; //母锁标识 uint uiType = 0; //产品类型 object vHID = null; //HID,硬件序列号 object vBirthday = null; //生产日期 ryArmDongle.GetDongleInfo(bDongleInfo, 0, ref uiVer, ref vBirthday, ref uiAgent, ref uiPID, ref uiUID, ref vHID, ref uiDevType, ref uiIsMother, ref uiType); byte[] hid = (byte[])vHID; string shid = string.Format("{0:X2}{1:X2}{2:X2}{3:X2}{4:X2}{5:X2}{6:X2}{7:X2}", hid[0], hid[1], hid[2], hid[3] , hid[4], hid[5], hid[6], hid[7]); DataInfo datainfo = new DataInfo(); datainfo.Code = 0; DogInfo dogInfo = new DogInfo(); dogInfo.HId = shid; //读用户信息文件 ushort usFileID = 0x1112; ushort usReadFileID = 0; object vFileListBuffer = null; uint uiFileListBufferLen = 0; ryArmDongle.ListFile(uiHandle, DongleDef.FILE_DATA, ref vFileListBuffer, ref uiFileListBufferLen, ref uiError); if (uiError != DongleDef.DONGLE_SUCCESS) { if (reInit()) { getDogInfo(); } else { return(null); } } int i = 0; uint uiSize = 1024; //文件大小 ushort usRead = 0; //读权限 ushort usWrite = 1; //写权限 while (true) { object vFileAttr = null; usReadFileID = 0; ryArmDongle.Convert_Buffer_To_FILE_LIST(vFileListBuffer, uiFileListBufferLen, (uint)i, DongleDef.FILE_DATA, ref usReadFileID, ref vFileAttr, ref uiError); if (uiError == DongleDef.DONGLE_INVALID_PARAMETER) { break; } if (usReadFileID == usFileID) { ryArmDongle.Convert_Buffer_To_DATA_FILE_ATTR(vFileAttr, ref uiSize, ref usRead, ref usWrite, ref uiError); break; } i++; } object vData = null; ryArmDongle.ReadFile(uiHandle, usFileID, 0, ref vData, uiSize, ref uiError); string sInfo = RUtils.ByteToString((byte[])vData); string[] aInfo = sInfo.Split(';'); if (aInfo.Length == 2) { dogInfo.Code = aInfo[0]; dogInfo.Name = aInfo[1]; } datainfo.Data = dogInfo; return(datainfo); }