Skip to content

Instantly share code, notes, and snippets.

@CanerPatir
Last active September 18, 2019 12:52
Show Gist options
  • Select an option

  • Save CanerPatir/f371568c393fd78a708d7707db63e832 to your computer and use it in GitHub Desktop.

Select an option

Save CanerPatir/f371568c393fd78a708d7707db63e832 to your computer and use it in GitHub Desktop.
fun main(){
launch(Dispatchers.IO) {
val user = api.fetchUserInfoAsync(id).await()
withContext(Dispatchers.Default) {
val hash = user.username.hash()
}
}
}
fun String.md5(): String {
val md = MessageDigest.getInstance("MD5")
return BigInteger(1, md.digest(toByteArray())).toString(16).padStart(32, '0')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment