public void TestEncryptor() { var keyValue = HMACSHA1Sign.CreatedSignKey(); string encryptorStr = HMACSHA1Sign.SignStr(input, keyValue); Assert.IsNotNull(encryptorStr); Assert.IsTrue(encryptorStr.Length > 0); Console.WriteLine(encryptorStr); }
public void TestDecryptor() { var keyValue = HMACSHA1Sign.CreatedSignKey(); string signedStr = HMACSHA1Sign.SignStr(input, keyValue); String outStr = String.Empty; var b = HMACSHA1Sign.VerifyStr(signedStr, keyValue, out outStr); Assert.IsNotNull(signedStr); Assert.IsTrue(signedStr.Length > 0); Console.WriteLine(signedStr); Assert.IsTrue(b); Assert.IsNotNull(outStr); Console.WriteLine(outStr); Assert.IsTrue(outStr.Equals(input)); }
private void btn_DoSign_Click(object sender, EventArgs e) { String sign = textBox_Sign.Text.Trim(), body = textBox_Body.Text.Trim(); if (String.IsNullOrEmpty(sign)) { MessageBox.Show("签名不能为空!", "温馨提示"); return; } if (String.IsNullOrEmpty(body)) { MessageBox.Show("待处理文本不能为空!", "温馨提示"); return; } textBox_Result.Text = HMACSHA1Sign.SignStr(body, sign); }