Ucloud API Signature Encryption Perl version

Source: Internet
Author: User
Tags sha1

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.