import random


def encode_string(value):
    """
    Encode a string into it's equivalent html entity.

    The tag will randomly choose to represent the character as a hex digit or
    decimal digit.
    """

    e_string = ""
    for a in value:
        e_type = random.randint(0, 1)
        if e_type:
            en = "&#x%x;" % ord(a)
        else:
            en = "&#%d;" % ord(a)
        e_string += en
    return e_string