We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
能否给出HmacSHA256的实现,使用JDK自带的HmacSHA256实现,无法与文档中对应。
JSONObject jsonObject = new JSONObject(); jsonObject.put("Bucket", "doc"); jsonObject.put("Object", "anne.jpg"); jsonObject.put("Expires", 1451491200); String encodedPutPolicy = new BASE64Encoder().encode(jsonObject.toJSONString().getBytes()); System.out.println("encodedPutPolicy:" + encodedPutPolicy); SecretKeySpec signingKey = new SecretKeySpec("ae0208eea57c4bc9bc5754368c06a542".getBytes(), "HmacSHA256"); Mac mac = Mac.getInstance(signingKey.getAlgorithm()); mac.init(signingKey); byte[] digest = mac.doFinal(encodedPutPolicy.getBytes("UTF-8")); String sign = new String(new Hex().encode(digest)); String encodedSign = new BASE64Encoder().encode(sign.getBytes()); System.out.println("encodedSign:" + encodedSign);
The text was updated successfully, but these errors were encountered:
HmacSHA256实现是统一标准的,另外代码也是开放的,你可以查看源码。
Sorry, something went wrong.
No branches or pull requests
能否给出HmacSHA256的实现,使用JDK自带的HmacSHA256实现,无法与文档中对应。
The text was updated successfully, but these errors were encountered: