HMACSHA1的密钥中的引号(“)

时间:2015-11-13 17:06:46

标签: c# hmacsha1

我的字符串

string key = "lw!'s"lI1p,,7#P9IQ1b";

此密钥用于我的HMAC-SHA1编码

public string Encode(string input, string key)
{
    HMACSHA1 myhmacsha1 = new HMACSHA1(Encoding.ASCII.GetBytes(key));
    byte[] byteArray = Encoding.ASCII.GetBytes(input);
    MemoryStream stream = new MemoryStream(byteArray);
    byte[] hashValue = myhmacsha1.ComputeHash(stream);
    return hashValue.ToString();
}

现在问题是我的密钥中有引号(“):

  

LW!的“lI1p ,, 7#P9IQ1b

我不知道如何处理“在字符串

我尝试在

中使用\
string key = "lw!'s\"lI1p,,7#P9IQ1b";

但似乎添加了\更改密钥和HMACSHA1加密后产生的字符串不是应该的。

有人可以告诉我如何让它发挥作用。

0 个答案:

没有答案