public void DecryptString() { var encrypted = DesUtility.EncryptStringToBytes_Des(originalText, Key, IV); var decryptedString = DesUtility.DecryptStringFromBytes_Des(encrypted, Key, IV); Assert.AreEqual(originalText, decryptedString); }
public int GetDecodedUserAvatar(string code, string encodeKey) { try { var content = DesUtility.DecryptDES(code, encodeKey); var datas = content.Split('|'); var dateTime = new DateTime(long.Parse(datas[0])); if ((DateTime.Now - dateTime).TotalSeconds > 15) { return(-1);//指定秒后失效 } var accountId = int.Parse(datas[1]); return(accountId); } catch { return(-1); } }
public string GetDecodedContent(string content, string encodeKey) { return(DesUtility.DecryptDES(content, encodeKey)); }
private void button6_Click(object sender, EventArgs e) { DesUtility des = new DesUtility(); textBox1.Text = des.Decrypt(textBox2.Text.Trim()); }
public void EncryptString() { var encrypted = DesUtility.EncryptStringToBytes_Des(originalText, Key, IV); Assert.AreNotEqual(originalText, encrypted.ToString()); }
public string GetEncodedUserAvatar(int accountId, string encodeKey) { var content = $"{DateTime.Now.Ticks}|{accountId}"; return(DesUtility.EncryptDES(content, encodeKey)); }
/// <summary> /// 通用解密 /// </summary> /// <param name="str"></param> /// <returns></returns> public string CommonDecrypt(string str) { var content = DesUtility.EncryptDES(str, BASE_ENCRYPT_ENCODING_KEY); return(str.Split('|')[0]); }
/// <summary> /// 通用加密 /// </summary> /// <param name="str"></param> /// <returns></returns> public string CommonEncrypt(string str) { var content = $"{str}|{BASE_ENCRYPT_ENCODING_KEY}"; return(DesUtility.EncryptDES(content, BASE_ENCRYPT_ENCODING_KEY)); }