[fpc-pascal] Re: AWS S3 RESTAuthentication
Marcos Douglas
md at delfire.net
Tue Jun 11 04:31:24 CEST 2013
On Mon, Jun 10, 2013 at 9:43 PM, Marcos Douglas <md at delfire.net> wrote:
> Hi,
>
> Someone know how translate the "code" bellow to Pascal?
> http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html
>
> === code ===
> Authorization = "AWS" + " " + AWSAccessKeyId + ":" + Signature;
>
> Signature = Base64( HMAC-SHA1( YourSecretAccessKeyID,
> UTF-8-Encoding-Of( StringToSign ) ) );
>
> StringToSign = HTTP-Verb + "\n" +
> Content-MD5 + "\n" +
> Content-Type + "\n" +
> Date + "\n" +
> CanonicalizedAmzHeaders +
> CanonicalizedResource;
>
> CanonicalizedResource = [ "/" + Bucket ] +
> <HTTP-Request-URI, from the protocol name up to the query string> +
> [ sub-resource, if present. For example "?acl", "?location",
> "?logging", or "?torrent"];
>
> CanonicalizedAmzHeaders = <described below>
>
> === code ===
>
> I tried something like:
>
> function StringToSign: string;
> begin
> Result := HTTPVerb + #10 // GET, PUT, etc
> + '' + #10 // ContentMD5
> + '' + #10 // ContentType
> + RfcDateValue + #10 // Date
> + '' // CanonicalizedAmzHeaders
> + '/'; //+BucketName; // CanonicalizedResource;
> end;
>
> function GetSignature: string;
> begin
> Result := EncodeBase64(HMACSHA1(FSecretKey, UTF8Encode(StringToSign)));
> end;
>
>
>
> Thank you very much.
>
> Marcos Douglas
Ok, I got it. ;-)
Marcos Douglas
More information about the fpc-pascal
mailing list