Talk:Base64 encode data

From Rosetta Code

Changes prior to promoting to full task[edit]

We should use some different, shorter test data. Right now, there are two problems:

  1. the output is really too long to include on the page, and
  2. there's no guarantee that the icon will stay the same.

Using a short piece of sample text would make it much more practical to include the output with the solution, so allowing everyone to trivially check their implementation. Once that's sorted out, there's no reason we shouldn't promote to a full task as there are plenty of implementations. –Donal Fellows (talk) 15:58, 11 May 2014 (UTC)

task requirements[edit]

Should the output be shown when converting the Rosetta Code icon (favicon.ico)?

I would prefer to show something shorter/smaller (and can be used to verify the various program's outputs) such as the five examples that the Wikipedia article on Base64   [1]   that were used as illustrations (as used in the REXX example). -- Gerard Schildberger (talk) 16:25, 27 August 2013 (UTC)

Now that I think of it I'd like it to split the task or to merge these tasks.
  • Base64 Encode a string
  • Base64 Encode an image
  • Base64 Decode a Base64'd string.
But these would require a change on the task requirements, I guess I didn't thought that well, before.. creating this draft. Rainb (talk) 04:37, 28 August 2013 (UTC)
That's why the task is first made a draft. --- to iron out the requirements and make the task clearer.   Currently, the requirement is to use/convert the   favicon.ico   (file),   but not to show the result.   How is anyone to know the currect result is if nobody compares/verifies the OUTPUTs?   I would like to see if the programming examples can correctly handle the various padding variations   (= and == and no equal signs).   Unfortunately, the file to be used doesn't have any   =   padding in the output.   So far, nobody has shown the 4,850 bytes of output ... until now. -- Gerard Schildberger (talk) 05:12, 28 August 2013 (UTC)

output from the REXX example using an eighty-byte wide screen:

AAABAAIAEBAAAAAAAABoBQAAJgAAACAAAAAAAACoCAAAjgUAACgAAAAQAAAAIAAAAAEACAAAAAAAQAE
AAAAAAAAAAAAAAAAAAAAAAAAAAAAA////AIaJhwBGSEcAv8LAACYpJwBqbWsA4+bkAKCjoQBXWlgAFx
kYAM7RzwA4OzkArbCuAHN2dADr7uwA/P/9AAADAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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S0tLS0tLS0tLS0tLSwE
B6QD5dHert8A4tLd+oPhL5ORLS0tLS0tLS0tLS0tLAQHpAItMpC0EdCwgJpDiAQEBAQEBAQEBAQEBAQ
EBAQEBAekA5AEB5G0Z5wEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQDmhYWG7u8z5oWFheaGhoaGhoaGh
oaGhoaGhoaGhYXpAP////8AAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAA
AQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAA
AAQAAAAEAAAABAAAAAQAAAAEAAAAB


-- Gerard Schildberger (talk) 05:12, 28 August 2013 (UTC)


You're completely right, I thought this image was small enough, apparently it wasn't small enough, so.. how do you upload images to this wiki? Rainb (talk) 12:18, 28 August 2013 (UTC)
I had the exact same problem a few years back.   One had to use the   Upload file   link at the bottom of the (left) sidebar, but I can't find it now. -- Gerard Schildberger (talk) 21:30, 28 August 2013 (UTC)
Image uploads are disabled. Security problems (and spammers). Not sure when we will be able to bring them back. --Mwn3d (talk) 13:54, 29 August 2013 (UTC)
Also I just remembered that some languages may have issues with requesting binary HTTP, perhaps we should omit the image from the task..? Rainb (talk) 12:27, 28 August 2013 (UTC)
Yes, I think omit using (web) images as input to Rosetta Code programs should be dropped.   For me, it's a bit of bother as my language-of-choice doesn't grab files from the web, so I have to download them first. -- Gerard Schildberger (talk) 21:08, 28 August 2013 (UTC)
Don't make downloading the file a requirement of the task itself; it's just a source of binary data, not an HTTP client task (we've got another task for that). But it is reasonable to have a defined input to work with so that outputs can be compared. (Note that whitespace differences in the output are going to have to be allowable; the base64 spec specifically allows them.) –Donal Fellows (talk) 10:31, 29 August 2013 (UTC)
There's not much logical difference between a string and an image at this level; you're really encoding a byte sequence (and logically you have to start by encoding both the string and the image as bytes before you can apply the encoding at all, even if that's typically trivial for ASCII strings). I'll rename the task though, probably to “Base64 encoding” so as to better reflect what the task actually asks for. I encourage writing a matching decoding task; we can put in cross links between the two too. –Donal Fellows (talk) 10:36, 29 August 2013 (UTC)
But the thing is that the current task requires downloading of a file from the Web, which is conceptually separate from base-64. And downloading from the Web may be a very complicated task or it may not be supported by standard libraries in some languages, so I don't think it should be included. --Spoon! (talk) 20:36, 29 August 2013 (UTC)

The Base64 for the image file seems to have changed (at least it's different than what's above. Can anyone verify this? --Spoon! (talk) 00:13, 9 September 2013 (UTC)

Trouble downloading icon programmatically[edit]

In the Python on my computer, if I do

urllib2.urlopen('http://rosettacode.org/favicon.ico')

, it gives a 403 error. And if I do

print urllib.urlopen('http://rosettacode.org/favicon.ico').read()

, I get HTML that, among other things, says

The owner of this website (rosettacode.org) has banned your access based on your browser's signature (a6d6708c9990293-ua48).

--Spoon! (talk) 23:47, 31 August 2013 (UTC)

I don't know much python but this gets the file
import socket
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect((socket.gethostbyname("rosettacode.org"),80))
s.send(bytes("GET /favicon.ico HTTP/1.1\r\nHost:rosettacode.org\r\n\r\n","ASCII"))
data = s.recv(1024)
s.close()
print(data)
Rainb (talk) 02:19, 1 September 2013 (UTC)