Smarter likely_hash_to_string() and likely_string_to_hash()