Saturday, September 16, 2006

base64 ( Python )

A friend emailed me. jpg hadn't been decoded.


------=_NextPart_000_7706_6ba_7d30
Content-Type: image/jpeg; name="image.jpg";
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="image.jpg";

/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJ
ChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/
2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgo
KCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAFQAYsDASIAAhEBAxEB/8QA
HwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUF
BAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkK
FhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1
dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXG
x8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEB
AQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAEC
AxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRom
JygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOE
hYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU
1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD0XXBmN2UA
AVzljcb5CJDiukvle5h2Kjc9eKzLPRDMZXkby44xkmvRezTPNWpRupEQkKCx
PpVZow7Dy1570+fy/LZ4pMsDjbS2Su/LcE1jayDlsKLX9zjHPsKrPp8hBLKT
6Zrciwi4eobuUovyMK5G5c25py2RzU1k6qWC4GaiCmBicVsvc+ahjZOSetZ9
..........


I used this code to decode the jpg.

##

import sys, base64
base64.decode(open(sys.argv[1],'rb'),open(sys.argv[2],'wb'))

##

ASPN

No comments: