fn api_sign(
        &self,
        uri_path: String,
        nonce: u64,
        body: &str,
    ) -> Result<HeaderValue> {
        if let Some(credentials) = &self.credentials {
            type HmacSha512 = Hmac<Sha512>;

            // API-Sign = Message signature using HMAC-SHA512 of (URI path +
            // SHA256(nonce + POST data)) and base64 decoded secret API key
            let sha_body = format!("{}{}", nonce, body);
            let sha = Sha256::digest(sha_body.as_bytes());

            let private_key = credentials.private_key()?;
            let mut mac = HmacSha512::new_from_slice(&private_key)?;
            let mut hmac_data = uri_path.into_bytes();
            hmac_data.append(&mut sha.to_vec());
            mac.update(&hmac_data);

            let b64 = base64::encode(mac.finalize().into_bytes());
            HeaderValue::from_str(&b64).map_err(Error::internal)
        } else {
            Err(Error::Unauthorized)
        }
    }
/// Generates the API-Sign header value.
Generates the API-Sign header value.
Generates the API - Sign header value .
fn api_sign(
        &self,
        uri_path: String,
        nonce: u64,
        body: &str,
    ) -> Result<HeaderValue> {
        if let Some(credentials) = &self.credentials {
            type HmacSha512 = Hmac<Sha512>;
            // API-Sign = Message signature using HMAC-SHA512 of (URI path +
            // SHA256(nonce + POST data)) and base64 decoded secret API key
            let sha_body = format!("{}{}", nonce, body);
            let sha = Sha256::digest(sha_body.as_bytes());
            let private_key = credentials.private_key()?;
            let mut mac = HmacSha512::new_from_slice(&private_key)?;
            let mut hmac_data = uri_path.into_bytes();
            hmac_data.append(&mut sha.to_vec());
            mac.update(&hmac_data);
            let b64 = base64::encode(mac.finalize().into_bytes());
            HeaderValue::from_str(&b64).map_err(Error::internal)
        } else {
            Err(Error::Unauthorized)
        }
    }
fn api_sign ( & self , uri_path : String , nonce : u64 , body : & str , ) -> Result < HeaderValue > { if let Some ( credentials ) = & self . credentials { type HmacSha512 = Hmac < Sha512 > ; // API-Sign = Message signature using HMAC-SHA512 of (URI path + // SHA256(nonce + POST data)) and base64 decoded secret API key let sha_body = format ! ( " " nonce body ) ; let sha = Sha256 :: digest ( sha_body . as_bytes ( ) ) ; let private_key = credentials . private_key ( ) ? ; let mut mac = HmacSha512 :: new_from_slice ( & private_key ) ? ; let mut hmac_data = uri_path . into_bytes ( ) ; hmac_data . append ( & mut sha . to_vec ( ) ) ; mac . update ( & hmac_data ) ; let b64 = base64 :: encode ( mac . finalize ( ) . into_bytes ( ) ) ; HeaderValue :: from_str ( & b64 ) . map_err ( Error :: internal ) } else { Err ( Error :: Unauthorized ) } }
Generates the API-Sign header value.
Generates the API - Sign header value .
&self
uri_path
String
nonce
u64
body
&str
&self
uri_path
String
nonce
u64
body
&str