rea*_*ure 0 java hash sha256 guava
我正在用Java浏览Java中的密码Hashing.
password = Hashing
.sha256()
.hashString(input, StandardCharsets.UTF_8)
.toString();
Run Code Online (Sandbox Code Playgroud)
当我将任何文本传递给该行时,它会散列并以小写字符输出所有内容,例如,如果我传递"foo",则值password变为:
2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae
Run Code Online (Sandbox Code Playgroud)
但是,如果我使用此站点来散列"foo",它输出的值是
2C26B46B68FFC68FF99B453C1D30413413422D706483BFA0F98A5E886266E7AE
Run Code Online (Sandbox Code Playgroud)
据我所知,这只是完全相同的密码,除了大写字母而不是小写字母.
导致那些输出不同值的原因是什么,以及如何使用大写字母输出番石榴(不需要调用toUpperCase,除非这是唯一的方法)
Guava以小写形式生成结果字符串的主要原因是因为:com.google.common.hash.HashCode.toString() method的实现.
您可以简单地toUpperCase()从String类中调用结果哈希字符串值的方法:
password = Hashing
.sha256()
.hashString(input, StandardCharsets.UTF_8)
.toString()
.toUpperCase();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
181 次 |
| 最近记录: |