Base64 decode encode, getting different data

user2206520

I am developing an amazon s3 app with golang. I'm having some trouble and confused.

From the aws s3 upload example the first step uses Base64 encoded:

{ "expiration": "2013-08-06T12:00:00.000Z",
  "conditions": [
    {"bucket": "examplebucket"},
    ["starts-with", "$key", "user/user1/"],
    {"acl": "public-read"},
    {"success_action_redirect": "http://acl6.s3.amazonaws.com/successful_upload.html"},
    ["starts-with", "$Content-Type", "image/"],
    {"x-amz-meta-uuid": "14365123651274"},
    ["starts-with", "$x-amz-meta-tag", ""],

    {"x-amz-credential": "AKIAIOSFODNN7EXAMPLE/20130806/us-east-1/s3/aws4_request"},
    {"x-amz-algorithm": "AWS4-HMAC-SHA256"},
    {"x-amz-date": "20130806T000000Z" }
  ]
}

I'm supposed to get:

eyAiZXhwaXJhdGlvbiI6ICIyMDEzLTA4LTA3VDEyOjAwOjAwLjAwMFoiLA0KICAiY29uZGl0aW9ucyI6IFsNCiAgICB7ImJ1Y2tldCI6ICJleGFtcGxlYnVja2V0In0sDQogICAgWyJzdGFydHMtd2l0aCIsICIka2V5IiwgInVzZXIvdXNlcjEvIl0sDQogICAgeyJhY2wiOiAicHVibGljLXJlYWQifSwNCiAgICB7InN1Y2Nlc3NfYWN0aW9uX3JlZGlyZWN0IjogImh0dHA6Ly9leGFtcGxlYnVja2V0LnMzLmFtYXpvbmF3cy5jb20vc3VjY2Vzc2Z1bF91cGxvYWQuaHRtbCJ9LA0KICAgIFsic3RhcnRzLXdpdGgiLCAiJENvbnRlbnQtVHlwZSIsICJpbWFnZS8iXSwNCiAgICB7IngtYW16LW1ldGEtdXVpZCI6ICIxNDM2NTEyMzY1MTI3NCJ9LA0KICAgIFsic3RhcnRzLXdpdGgiLCAiJHgtYW16LW1ldGEtdGFnIiwgIiJdLA0KDQogICAgeyJ4LWFtei1jcmVkZW50aWFsIjogIkFLSUFJT1NGT0ROTjdFWEFNUExFLzIwMTMwODA2L3VzLWVhc3QtMS9zMy9hd3M0X3JlcXVlc3QifSwNCiAgICB7IngtYW16LWFsZ29yaXRobSI6ICJBV1M0LUhNQUMtU0hBMjU2In0sDQogICAgeyJ4LWFtei1kYXRlIjogIjIwMTMwODA2VDAwMDAwMFoiIH0NCiAgXQ0KfQ==

However, I get a different result:

eyAiZXhwaXJhdGlvbiI6ICIyMDEzLTA4LTA2VDEyOjAwOjAwLjAwMFoiLAogICJjb25kaXRpb25zIjogWwogICAgeyJidWNrZXQiOiAiZXhhbXBsZWJ1Y2tldCJ9LAogICAgWyJzdGFydHMtd2l0aCIsICIka2V5IiwgInVzZXIvdXNlcjEvIl0sCiAgICB7ImFjbCI6ICJwdWJsaWMtcmVhZCJ9LAogICAgeyJzdWNjZXNzX2FjdGlvbl9yZWRpcmVjdCI6ICJodHRwOi8vYWNsNi5zMy5hbWF6b25hd3MuY29tL3N1Y2Nlc3NmdWxfdXBsb2FkLmh0bWwifSwKICAgIFsic3RhcnRzLXdpdGgiLCAiJENvbnRlbnQtVHlwZSIsICJpbWFnZS8iXSwKICAgIHsieC1hbXotbWV0YS11dWlkIjogIjE0MzY1MTIzNjUxMjc0In0sCiAgICBbInN0YXJ0cy13aXRoIiwgIiR4LWFtei1tZXRhLXRhZyIsICIiXSwKCiAgICB7IngtYW16LWNyZWRlbnRpYWwiOiAiQUtJQUlPU0ZPRE5ON0VYQU1QTEUvMjAxMzA4MDYvdXMtZWFzdC0xL3MzL2F3czRfcmVxdWVzdCJ9LAogICAgeyJ4LWFtei1hbGdvcml0aG0iOiAiQVdTNC1ITUFDLVNIQTI1NiJ9LAogICAgeyJ4LWFtei1kYXRlIjogIjIwMTMwODA2VDAwMDAwMFoiIH0KICBdCn0=

Why am I getting a different result then expected?

laffuste

Did you know base64 can be decoded as well as encoded? It is not an encryption algorithm, it is a codification. There are many base64 encoding/decoding online services.

If you decode it, you can see the amazon provided one has this value:

action_redirect: http://examplebucket.s3.amazonaws.com/successful_upload.html

expiration also differs. They probably didn't update the encoded string after changing the json example.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Different output after decode and encode data (base64)

From Dev

Apache codec base64 encode/decode - not getting expected result

From Java

Base64 Java encode and decode a string

From Dev

BASE64 Encode and Decode is not working

From Dev

base64 encode in python, decode in javascript

From Dev

base64 decode/encode inconsistency

From Dev

Google Protocol Buffers - Confused about encode decode base64 char * c string protocol buffer data

From Dev

Php base base64 encode and decode not working correctly

From Java

How do I encode and decode a base64 string?

From Dev

base64 encode, decode to, from files in chunks with python 2.7

From Java

How to Convert Pdf to base64 and Encode / Decode

From Dev

Unable to make Guava base64 encode/decode work

From Dev

Encode UIImage in iOS7 and Decode it in Java (Base64)

From Dev

Base64 encode/decode without padding on golang ( appengine )

From Dev

How to Convert Pdf to base64 and Encode / Decode

From Dev

Extra new lines on base64 encode/decode in Python?

From Dev

Encode UIImage in iOS7 and Decode it in Java (Base64)

From Dev

Base64: how to encode / decode the entire HTML code of a page

From Dev

Base64 Encode/Decode in Nativescript With Angular 2

From Dev

Encode base64 in Python and decode in C#

From Java

Decode Base64 data in Java

From Dev

Decode base64 data encoded in bash

From Dev

JavaScript: Decode base64 into binary data

From Dev

BASE64 decode and ungzip data in PHP

From Dev

Encode base64 and Decode base64 using delphi 2007

From Dev

Encode base64 and Decode base64 using delphi 2007

From Java

How to encode and decode Base64 and Base64Url in Flutter / Dart

From Dev

different results when I encode a character to base64

From Dev

Android Base64 decode different from javascript and PhP

Related Related

  1. 1

    Different output after decode and encode data (base64)

  2. 2

    Apache codec base64 encode/decode - not getting expected result

  3. 3

    Base64 Java encode and decode a string

  4. 4

    BASE64 Encode and Decode is not working

  5. 5

    base64 encode in python, decode in javascript

  6. 6

    base64 decode/encode inconsistency

  7. 7

    Google Protocol Buffers - Confused about encode decode base64 char * c string protocol buffer data

  8. 8

    Php base base64 encode and decode not working correctly

  9. 9

    How do I encode and decode a base64 string?

  10. 10

    base64 encode, decode to, from files in chunks with python 2.7

  11. 11

    How to Convert Pdf to base64 and Encode / Decode

  12. 12

    Unable to make Guava base64 encode/decode work

  13. 13

    Encode UIImage in iOS7 and Decode it in Java (Base64)

  14. 14

    Base64 encode/decode without padding on golang ( appengine )

  15. 15

    How to Convert Pdf to base64 and Encode / Decode

  16. 16

    Extra new lines on base64 encode/decode in Python?

  17. 17

    Encode UIImage in iOS7 and Decode it in Java (Base64)

  18. 18

    Base64: how to encode / decode the entire HTML code of a page

  19. 19

    Base64 Encode/Decode in Nativescript With Angular 2

  20. 20

    Encode base64 in Python and decode in C#

  21. 21

    Decode Base64 data in Java

  22. 22

    Decode base64 data encoded in bash

  23. 23

    JavaScript: Decode base64 into binary data

  24. 24

    BASE64 decode and ungzip data in PHP

  25. 25

    Encode base64 and Decode base64 using delphi 2007

  26. 26

    Encode base64 and Decode base64 using delphi 2007

  27. 27

    How to encode and decode Base64 and Base64Url in Flutter / Dart

  28. 28

    different results when I encode a character to base64

  29. 29

    Android Base64 decode different from javascript and PhP

HotTag

Archive