I need encriptar
the IMEI
en MD5
, does anyone know how it would be done? I manage to get the IMEI
but for the encriptación
.
I need encriptar
the IMEI
en MD5
, does anyone know how it would be done? I manage to get the IMEI
but for the encriptación
.
You don't encrypt
MD5
, what you do is hashMD5
. You can do it withMessageDigest
:I think it
MessageDigest#getInstance
throws oneNoSuchAlgorithmException
if you try to get a nonexistent hashing algorithm, so you'll have to do a try catch.To obtain the MD5 of the IMEI , I share a method using the MessageDigest class :
Method to generate MD5 code from a string in Android:
You can call it like this to get the MD5 (hash not string encryption) of your IMEI:
To obtain the IMEI of your device, this would be the way using the TelephonyManager class :
Another method which is recommended is using Settings.Secure.ANDROID_ID , which gets an ID as a unique 64 bit hexadecimal string.
remember to add the permission in your
AndroidManifest.xml
:Another method to get the
md5
from a string.Adapting the code with the suggestions of Android Studio 2.1
Its use