我试图从一个字符串计算一个SHA-1哈希,但是当我使用php的sha1函数计算字符串时,我得到的东西比我在C#中尝试时有所不同.我需要C#来计算与PHP相同的字符串(因为php中的字符串是由我无法修改的第三方计算的).如何让C#生成与PHP相同的哈希?谢谢!!!
String = s934kladfklada@a.com
C#代码(生成d32954053ee93985f5c3ca2583145668bb7ade86)
string encode = secretkey + email;
UnicodeEncoding UE = new UnicodeEncoding();
byte[] HashValue, MessageBytes = UE.GetBytes(encode);
SHA1Managed SHhash = new SHA1Managed();
string strHex = "";
HashValue = SHhash.ComputeHash(MessageBytes);
foreach(byte b in HashValue) {
strHex += String.Format("{0:x2}", b);
}
Run Code Online (Sandbox Code Playgroud)
PHP代码(生成a9410edeaf75222d7b576c1b23ca0a9af0dffa98)
sha1();
Run Code Online (Sandbox Code Playgroud) Hey everyone, I am trying to hide/show different html elements (div, etc...) based on whether a checkbox is checked or if a specific value is chosen from a dropdown box. I was wondering if someone can help me out. The html element is defined along the lines of this (below), and i'm not sure how to reference it by name with brackets in it. The page i'm using has jquery enabled, and i'd like to use it if possible. Thanks! …
c# ×1
cryptographic-hash-function ×1
cryptography ×1
forms ×1
html ×1
javascript ×1
jquery ×1
php ×1
sha1 ×1