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());
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/10996.html