View difference between Paste ID: XTQSh61C and VXe0dhPj
SHOW: | | - or go back to the newest paste.
1
#!/usr/bin/env python
2
3
# Simple script to encode and decode base64
4
# Coded by MatriX Coder | www.matrixcoder.co.vu | www.fb.com/matrixcoder2
5
6
from Tkinter import *
7
import base64
8
import tkMessageBox
9
10
11
def base():
12
    choose = var.get()
13
    txt1 = text1.get("1.0", END)
14
    txt2 = text2.get("1.0", END)
15
    if choose == 1:
16
        # So we will Encode
17
        base64_encode = base64.b64encode(txt1)
18
        if base64_encode == "Cg==":
19
            tkMessageBox.showerror("Empty Text", "Please fill the textbox")
20
        else:
21
            text2.insert("1.0", base64_encode)
22
    elif choose == 2:
23
        # So we will Decode
24
        base64_decode = base64.b64decode(txt2)
25
        if base64_decode == "":
26
            tkMessageBox.showerror("Empty Text", "Please fill the textbox")
27
        else:
28
            text1.insert("1.0", base64_decode)
29
    else:
30
        tkMessageBox.showerror("Take a choice!", "Please choose to Encode or to Decode!")
31
32
root = Tk()
33
root.wm_title("Base64 Encode/Decode [By MatriX Coder]")
34
text1 = Text(root)
35
text1.pack()
36
but = Button(root, text="GO!", command=base).pack()
37
var = IntVar()
38
radio1 = Radiobutton(root, text="Encode", variable=var, value=1)
39
radio1.pack()
40
radio2 = Radiobutton(root, text="Decode", variable=var, value=2)
41
radio2.pack()
42
text2 = Text(root)
43
text2.pack()
44
root.mainloop()