是否每个Android手机支持SHA-256 [英] Does every Android phone support SHA-256

查看:162
本文介绍了是否每个Android手机支持SHA-256的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

那么阅读这篇文章:<一个href="http://stackoverflow.com/questions/7166129/how-can-i-calculate-the-sha-256-hash-of-a-string-in-android">How我可以计算一个字符串中的Andr​​oid的SHA-256散列?

和文档:<一href="http://developer.android.com/reference/java/security/MessageDigest.html">http://developer.android.com/reference/java/security/MessageDigest.html

我很好奇;该手机将支持SHA-256?在文档,关于抛出:NoSuchAlgorithmException行让我觉得有些手机不支持所有的算法。在我去实现这一个应用程序,并期待它在所有的手机,我想知道如果任何人知道这事的工作一样...?

I'm curious; which phones will support SHA-256? In the docs, the line about the 'NoSuchAlgorithmException' makes me think that some phones don't support all algorithms. Before I go implementing this for an app and expecting it to work the same on all phones I want to know if anyone knows anything about this...?

我觉得奇怪的是MessageDigest类所没有的一些常量来接你要使用的算法。

I find it strange that the MessageDigest class doesn't have some constants to pick the algorithm you want to use.

推荐答案

所有的Andr​​oid设备都支持SHA-256。该抛出:NoSuchAlgorithmException 指示请求的算法无法找到,是必要的,因为该方法需要一个字符串参数的算法名称。如果你在为foo-256通过,该方法的唯一的办法就是抛出一个抛出:NoSuchAlgorithmException 因为,我不明白的原因,没有算法被称为富-256。假设你传递你确定一个名称是一种算法,机器人可以使用,你永远不会看到这个异常。

All Android devices support SHA-256. The NoSuchAlgorithmException indicates that a requested algorithm could not be found and is necessary because the method takes a String argument for the algorithm name. If you passed in "foo-256", the method's only recourse is to throw a NoSuchAlgorithmException because, for reasons beyond my understanding, there's no algorithm called "foo-256". Assuming you're passing in a name you're sure is an algorithm that Android can use, you'll never see that exception.

这篇关于是否每个Android手机支持SHA-256的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆