import hashlib


def _encode_luci_string(unencoded_string):
    """Encodes a string to be sent to a G3100 gateway in a "luci_" POST parameter."""
    md5_hash = hashlib.md5(unencoded_string.encode('ascii')).hexdigest()
    return hashlib.sha512(md5_hash.encode('ascii')).hexdigest()