简体   繁体   中英

asp.net to php encoding

I need to do this with php encryption method. turkey 3d a bank payment module in the code for the example given to me in this way encryption. could you help me translate this into php code?

    SHA1 sha1 = new SHA1CryptoServiceProvider();
    byte[] notHashedBytes = System.Text.Encoding.ASCII.GetBytes(notHashedStr);
    byte[] hashedByte = sha1.ComputeHash(notHashedBytes);
    string hashedStr = System.Convert.ToBase64String(hashedByte);
    return hashedStr;

I know nothing about.Net but from what I gathered in this page seems like the PHP equivalent is just:

$hashedStr = base64_encode(sha1($notHashedStr, true));

You need to encode the raw binary format and not the hexadecimal representation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM