The method of encrypting signature in Ucloud API document is not clear, and there is no Perl version, specially wrote a copy for everyone to refer
UseUri::Escape; UseUTF8; UseEncode; UseANYEVENT::HTTP::LWP::useragent; UseDigest::SHA QW (SHA1 sha1_hex sha1_base64);SubUcloudapiconn {my($publicKey,$privateKey,$BASEURL,$paramData) =@_; #defining signature stitching strings, HTTP strings my($signatureStr,$params ); my $ua= lwp::useragent->new; for my $key(Sort Keys%$paramData ) { $signatureStr.=$key; $signatureStr.=$paramData->{$key}; #convert the HTTP string to URI mode Push@{$params},"$key =". Uri_escape_utf8 ($paramData->{$key} ); } #Stitching private Key $signatureStr.=$privateKey; #encrypting using the SHA1 algorithm my $signatureKey= Sha1_hex ($signatureStr); #URL parameters for stitching pass my $PARAMURL=Join "&", @$params; $PARAMURL=$PARAMURL."&"."signature= $signatureKey"; my $url="$baseUrl/?".$PARAMURL; Print $url,"\ n"; return $url;}
Ucloud API Signature Encryption Perl version