我在调试我自定义的OAuth实现(shindig
和spring-security-oauth
库)。比较字节[]和String.getBytes()
无论shindig和spring-security的细节如何,我使用sha()
创建一个散列,然后将它传递给spring-security-oauth。我希望哈希值是平等的,但它们不是。
狂欢
bytes[] shindigHash = sha(someBytes);
// docs for sha()
弹簧安全的OAuth
bytes[] b = str.getBytes("UTF-8");` // String str passed in from
我也试过bytes[] b = str.getBytes();
默认编码,但它不等于shindigHash
时我比较了b
和shindigHash
的元素。
编辑
for j = 0 .. b.length // same as shindigHash length
print shindigHash[j] ... b[j]
end
visually compare results
str从哪里来?你如何比较字节数组?另外,sha()已被弃用。 – Antimony 2013-04-25 00:20:59
@Antimony,根据你的“比较”问题进行更新。我宁愿保留相同的库,即不更新已弃用的sha(),因为多个项目使用它。 – 2013-04-25 00:24:39