'Translate Authorization code from C# to Python3.x

Hi can anyone please help me translate this Auth code from C# to Python3.x? Thanks.

private static string GetSignature(string args, string privatekey) 
{ 
    var encoding = new System.Text.UTF8Encoding(); 
    byte[] key = encoding.GetBytes(privatekey); 
    var myhmacsha256 = new HMACSHA256(key); 
    byte[] hashValue = myhmacsha256.ComputeHash(encoding.GetBytes(args)); 
    string hmac64 = Convert.ToBase64String(hashValue); 
    myhmacsha256.Clear(); 
    return hmac64; 
}

Sorry if this look quite simple but I don't know much about C# and this is quite hard to understand this.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source