def do_hash(hash_algo, marfile, asn1=False):
    """Output the hash for this MAR file."""
    # Add a dummy signature into a temporary file
    dst = tempfile.TemporaryFile()
    with open(marfile, 'rb') as f:
        add_signature_block(f, dst, hash_algo)

    dst.seek(0)

    with MarReader(dst) as m:
        hashes = m.calculate_hashes()
        h = hashes[0][1]
        if asn1:
            h = format_hash(h, hash_algo)

        print(base64.b64encode(h).decode('ascii'))
def do_hash ( hash_algo , marfile , asn1 = False ) : dst = tempfile . TemporaryFile ( ) with open ( marfile , 'rb' ) as f : add_signature_block ( f , dst , hash_algo ) dst . seek ( 0 ) with MarReader ( dst ) as m : hashes = m . calculate_hashes ( ) h = hashes [ 0 ] [ 1 ] if asn1 : h = format_hash ( h , hash_algo ) print ( base64 . b64encode ( h ) . decode ( 'ascii' ) )
Output the hash for this MAR file.