Session 散列会话密钥
我正在尝试散列会话密钥,但遇到一个错误,即无法从字符串转换为字节[] 我假设散列将其存储在字节数组中,但为什么它会在会话键变量上抛出错误呢Session 散列会话密钥,session,hash,.net-core,Session,Hash,.net Core,我正在尝试散列会话密钥,但遇到一个错误,即无法从字符串转换为字节[] 我假设散列将其存储在字节数组中,但为什么它会在会话键变量上抛出错误呢 var Sha1Hash = System.Security.Cryptography.SHA1.Create(); var hash = Sha1Hash.ComputeHash(HttpContext.Session.GetString(SessionKeyName)); 您需要将字符串(HttpContext.Session.GetString(S
var Sha1Hash = System.Security.Cryptography.SHA1.Create();
var hash = Sha1Hash.ComputeHash(HttpContext.Session.GetString(SessionKeyName));
您需要将字符串(
HttpContext.Session.GetString(SessionKeyName)
)转换为字节数组
var hash = Sha1Hash.ComputeHash(Encoding.ASCII.GetBytes(HttpContext.Session.GetString(SessionKeyName)));