Commit b7180071 authored by nobodyiam's avatar nobodyiam Committed by Jason Song

use guava base64 instead of javax.xml.bind.DatatypeConverter to support java 11

parent fb9b24a7
package com.ctrip.framework.apollo.core.signature; package com.ctrip.framework.apollo.core.signature;
import javax.crypto.Mac; import com.google.common.io.BaseEncoding;
import javax.crypto.spec.SecretKeySpec;
import javax.xml.bind.DatatypeConverter;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException; import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
/** /**
* @author nisiyong * @author nisiyong
...@@ -23,9 +23,9 @@ public class HmacSha1Utils { ...@@ -23,9 +23,9 @@ public class HmacSha1Utils {
ALGORITHM_NAME ALGORITHM_NAME
)); ));
byte[] signData = mac.doFinal(stringToSign.getBytes(ENCODING)); byte[] signData = mac.doFinal(stringToSign.getBytes(ENCODING));
return DatatypeConverter.printBase64Binary(signData); return BaseEncoding.base64().encode(signData);
} catch (NoSuchAlgorithmException | UnsupportedEncodingException | InvalidKeyException e) { } catch (NoSuchAlgorithmException | UnsupportedEncodingException | InvalidKeyException e) {
throw new IllegalArgumentException(e.toString()); throw new IllegalArgumentException(e.toString());
} }
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment