def asn1_length(n):
    """Return a string representing a field length in ASN.1 format.

    @param n: integer field length
    @return: ASN.1 field length
    """
    assert n >= 0
    if n < 0x7f:
        return bytearray([n])
    r = bytearray()
    while n > 0:
        r.insert(n & 0xff)
        n >>= 8
    return r
Return a string representing a field length in ASN.1 format.

    @param n: integer field length
    @return: ASN.1 field length
    
python/dkim/asn1.py