Inefficient new method from hashlib
The constructors for the `hashlib` module are faster than `new()`. We recommend using `hashlib` constructors instead.
def constructor_noncompliant():
    import hashlib

    text = "ExampleString"

    # Noncompliant: uses the new() constructor instead of the hashlib
    # constructor, which is slower.
    result = hashlib.new('sha256', text.encode())

    print("The hexadecimal equivalent of SHA256 is : ")
    print(result.hexdigest())
def constructor_compliant():
    import hashlib

    text = "ExampleString"

    # Compliant: uses the hashlib constructor over the new(), which is faster.
    result = hashlib.sha256(text.encode())

    print("The hexadecimal equivalent of SHA256 is : ")
    print(result.hexdigest())