use calc_hmac_sha1_as_base64
This commit is contained in:
@@ -89,7 +89,7 @@ impl OSSClient {
|
||||
signed_url.push_str(&format!("&OSSAccessKeyId={}", &urlencoding::encode(&self.access_key_id)));
|
||||
|
||||
let to_be_signed = get_to_be_signed(verb, expire_secs, bucket_name, key);
|
||||
let signature = calc_hmac_sha1(self.access_key_secret.as_bytes(), to_be_signed.as_bytes());
|
||||
let signature = calc_hmac_sha1_as_base64(self.access_key_secret.as_bytes(), to_be_signed.as_bytes());
|
||||
signed_url.push_str(&format!("&Signature={}", &urlencoding::encode(&signature)));
|
||||
|
||||
signed_url
|
||||
@@ -117,7 +117,7 @@ fn get_to_be_signed(verb: &str, expire_secs: u64, bucket_name: &str, key: &str)
|
||||
to_be_signed
|
||||
}
|
||||
|
||||
fn calc_hmac_sha1(key: &[u8], message: &[u8]) -> String {
|
||||
fn calc_hmac_sha1_as_base64(key: &[u8], message: &[u8]) -> String {
|
||||
Hmac::<Sha1>::new_varkey(key).map(|mut mac| {
|
||||
mac.input(message);
|
||||
base64::encode(&mac.result().code())
|
||||
|
||||
Reference in New Issue
Block a user