Is SHA-256 Case Insensitive?

后端 未结 4 481
予麋鹿
予麋鹿 2021-01-17 10:21

I\'m running a service that is using SHA-256 on two sides of the application - one is a server-side PHP implementation and the other is a client-side iOS implementation. The

相关标签:
4条回答
  • 2021-01-17 10:27

    All SHA series are binary algorithms they know nothing about case, so they can't be case insensitive.
    You can simply test this on single machine with 2 outputs from one string with different cases and you can see that they provide different results.
    In your case I think if every thing is ok, possibly iOS show capitalized string in the phone but internally pass you normal( lower case ) string

    0 讨论(0)
  • 2021-01-17 10:33

    No decent cryptographic hash function is case insensitive, because then it would be far easier to produce a collision. The output is a different matter. It's basically a large number (so casing does not apply), but for convenience it is given in base 16, i.e. using the letters a through f as additional digits. Hexadecimal notation is indeed case insensitive, or at least both upper- and lowercase variants are common and recognized. It doesn't matter and does not change what number is represented.

    0 讨论(0)
  • 2021-01-17 10:41

    If the binary representation of the input is the same on both sides the binary representation of the hash value will be the same. Hex is case insensitive.

    0 讨论(0)
  • 2021-01-17 10:52

    If you are referring to a hexadecimal string output, then yes, that is case insensitive. It is a textual representation of binary data.

    http://en.wikipedia.org/wiki/Hexadecimal

    The algorithm itself is most definitely case-sensitive.

    0 讨论(0)
提交回复
热议问题