Java使用HMAC-SHA1算法

2015-02-22 0 988
Java使用HMAC-SHA1算法
String secret = mConsumerSecret + "&" + mOauthToken;

SecretKey secretKey = new SecretKeySpec(secret.getBytes("US-ASCII"), "HmacSHA1");
Mac mac = Mac.getInstance("HmacSHA1");
mac.init(secretKey);

byte[] text = builder.toString().getBytes("US-ASCII");
byte[] finalText = mac.doFinal(text);
String base64Text = Base64.encodeToString(finalText, Base64.DEFAULT);
return encode(base64Text.trim());

遇见资源网 java Java使用HMAC-SHA1算法 http://www.ox520.com/8513.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务