Android Kotlin MD5, PHP MD5 alternative

masterjosh
by
masterjosh
Jan 10, 2019
Android Kotlin MD5, PHP MD5 alternative

Hi Dev,

this pretty little snippet am about to share, will allow you to hash string to md5 hash...

Fun/method code named md5 


fun md5(input: String): String? {
        return try {
            val md = MessageDigest.getInstance("MD5")
            val md5Data = BigInteger(1, md.digest(input.toByteArray()))
            String.format("%032X", md5Data).toLowerCase()
        } catch (e: NoSuchAlgorithmException) {
            e.printStackTrace()
            null
        }
    }

are you have any problem using this code ?

i will be happy to help via comment section 

Happy Coding!




Add Comment