<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def HA1(realm, username, password, algorithm):
 """Create HA1 hash by realm, username, password HA1 = md5(A1) = MD5(username:realm:password) """

    if not realm:
        realm = u''
    return H(b":".join([username.encode('utf-8'),
                           realm.encode('utf-8'),
                           password.encode('utf-8')]), algorithm)