fun hashKeyForDisk(key: String): String? { var cacheKey: String? try { val mDigest: MessageDigest = MessageDigest.getInstance("MD5") mDigest.update(key.toByteArray()) cacheKey = bytesToHexString(mDigest.digest()) } catch (e: NoSuchAlgorithmException) { cacheKey = key.hashCode().toString() } return cacheKey }
A hashing method that changes a string ( like a URL ) into a hash suitable for using as a disk filename .