The problem was probably when I was coordinating with a Cuban code. I don’t know what digest() is. There was no Internet, and then I figured it out


Python hashlib. Sha256 (XXX). The digest ()

After sha256, digest() is a binary array object equivalent to byte[] for C#

Python code

    import hashlib
    hash = hashlib.sha256("ABC").digest()Copy the code

C # code

        string str = "ABC";
        byte[] bytes = Encoding.UTF8.GetBytes(str);
        byte[] hash = SHA256Managed.Create().ComputeHash(bytes);Copy the code

Python hashlib. Sha256 (XXX). Hexdigest ()

After sha256, hexdigest() is a hexadecimal array object equivalent to C# byte[].

Python code

    import hashlib
    name1 = hashlib.sha256("ABC").hexdigest()Copy the code

C#

    static void Main(string[] args)
            {
                string str = "ABC"; str = sha256(str).ToLower(); Sha256 (STR).hexdigest()} public static string sha256(string data) {byte[] bytes = Encoding.UTF8.GetBytes(data); byte[]hash = SHA256Managed.Create().ComputeHash(bytes);
    
                StringBuilder builder = new StringBuilder();
                for (int i = 0; i < hash.Length; i++)
                {
                    builder.Append(hash[i].ToString("X2"));
                }
    
                return builder.ToString();
    
            }



Copy the code