How to reproduce System.Security.Cryptography.SHA1Managed result in Python

后端 未结 5 680
梦毁少年i
梦毁少年i 2021-01-17 03:07

Here\'s the deal: I\'m moving a .NET website to Python. I have a database with passwords hashed using the System.Security.Cryptography.SHA1Managed utility.

I\'m cre

5条回答
  •  旧巷少年郎
    2021-01-17 03:55

    When you use the string CreateHash(string, string) overload, the following occurs:

    1. The string is converted to bytes using UTF16 (using Encoding.Unicode.GetBytes()).
    2. A random 16-byte salt is generated.
    3. The salt is appended to the converted string and hashed.
    4. The salt is appended to the hash.
    5. The hash+salt is converted back to a string using base64 (using Convert.ToBase64String()).

提交回复
热议问题