def bin2hex(strbin):
    """
    Convert a string representing a binary number into a string
    representing the same value in hexadecimal format.
    """
    dic = { "0000":"0",
            "0001":"1",
            "0010":"2",
            "0011":"3",
            "0100":"4",
            "0101":"5",
            "0110":"6",
            "0111":"7",
            "1000":"8",
            "1001":"9",
            "1010":"A",
            "1011":"B",
            "1100":"C",
            "1101":"D",
            "1110":"E",
            "1111":"F"
    }
    while strbin.__len__()%4 != 0:
        strbin = '0' + strbin
    strh = ""
    for i in range(0, strbin.__len__()/4):
        strh = strh + dic[str(strbin[i*4:i*4+4])]
    return strh