@staticmethod<EOL><INDENT>def hash_host(hostname, salt=None):<DEDENT>
if salt is None:<EOL><INDENT>salt = os.urandom(sha1().digest_size)<EOL><DEDENT>else:<EOL><INDENT>if salt.startswith("<STR_LIT>"):<EOL><INDENT>salt = salt.split("<STR_LIT:|>")[<NUM_LIT:2>]<EOL><DEDENT>salt = decodebytes(b(salt))<EOL><DEDENT>assert len(salt) == sha1().digest_size<EOL>hmac = HMAC(salt, b(hostname), sha1).digest()<EOL>hostkey = "<STR_LIT>".format(u(encodebytes(salt)), u(encodebytes(hmac)))<EOL>return hostkey.replace("<STR_LIT:\n>", "<STR_LIT>")<EOL>
Return a "hashed" form of the hostname, as used by OpenSSH when storing
hashed hostnames in the known_hosts file.

:param str hostname: the hostname to hash
:param str salt: optional salt to use when hashing
    (must be 20 bytes long)
:return: the hashed hostname as a `str`