问题
I want to know if the MD5 digest algorithm is guaranteed to be available in all Android devices before I bluntly ignore the checked exception that MessageDigest.getInstance("MD5")
can throw.
回答1:
The Android JCE (Java Cryptography Extension) is based off the bouncycastle implementation but stripped down. bouncycastle provides a ton of different MessageDigests which can be found here.
There's no guarantee that every Android device supports MD5 but it's extremely common and is likely to be on every device as it's supported in bouncycastle. If you want to know if the device supports MD5 you can check the algorithms the device supports. More on that is here.
回答2:
I'm getting java.security.NoSuchAlgorithmException: MessageDigest MD5 implementation not found
on some devices. Here's the list:
GT-I8190
GT-I9100
GT-P3100
GT-S7562
HTC EVO 3D X515m
HTC Sensation 4G
HTC Sensation XL with Beats Audio X315b
LGL86C
LT22i
LT25i
LT26i
LT26ii
LT29i
SAMSUNG-SGH-I727
SGH-T769
SHV-E160K
SM-T211
ST21i
ST23i
ST26i
T7
and others.
This is statistics mainly for Indonesia though. The funny point is, the statistics is provided by Crittercism, and the exception is thrown by Crittercism too (looks like it uses MD5 in latest versions).
来源:https://stackoverflow.com/questions/14139684/is-md5-guaranteed-to-be-available-for-use-with-messagedigest-in-android