Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-06

AWS S3 RESTAuthentication

2 messages · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marcos Douglas

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

Reply by email

Marcos Douglas
to Marcos Douglas
Marcos Douglas wrote 49 lines
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

Reply by email