1

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;
1
  • i could be wrong but I think you need to include the SHA1CryptoServiceProvider() object Commented Apr 29, 2011 at 23:29

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

@hakan: And it doesn't work? Also, could you post a dummy input string and the corresponding output hash?
i use this code $hashedStr = base64_encode(sha1($notHashedStr)); output hash not correct

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.