Text To hexa - python (Source Code) Rahman Surya Praja Jumat, 21 Mei 2010 1 Comment

 Source Code Text To Hexa and Hexa To Text using python.

Snippet : http://www.dreamincode.net/code/snippet4581.htm


#!/usr/bin/python
print "\n###############################################################"
print "##                     {{{ Text To Hexa }}}                  ##"
print "##                     {{{ HEXA To Text }}}                  ##"
print "##                    vir0e5 -[ Rahman Surya ]-              ##"
print "## vir0e5 | NKRI                                             ##"
print "## STMIK DCI Tasikmalaya                                     ##"
print "## Notice : BOYCOTT MALAYSIAN PRODUCT FOR HUMAN RIGHTS!!!    ##"
print "############################################################### \n"
from Tkinter import *
     

from binascii import *

class AsciiHex:
  def __init__(self, master):
    frame = Frame(master)
    frame.pack()
    frame.master.title('Text to Hexa by: vir0e5')
     

    self.lascii = Label(frame, text='Text:')
    self.lascii.grid(row=0, column=0)

    self.lhex = Label(frame, text='Hexa:')
    self.lhex.grid(row=0, column=3)

    self.tascii = Text(frame, width = 45, height=16)
    self.tascii.grid(row=1, column=0, rowspan=2)

    self.thex = Text(frame, width = 45, height=16)
    self.thex.grid(row=1, column=3, rowspan=2)

    self.bascii = Button(frame, text='Text->Hexa',width = 10, height=1, command=self.asciihex)
    self.bascii.grid(row=1, column=2)

    self.bhex = Button(frame, text='Text<-Hexa', width = 10, height=1,command=self.hexascii)
    self.bhex.grid(row=2, column=2)

   
    self.footer = Button(frame, text='Exit',width = 10, height=1, foreground='blue',
                      command=quit  )
    self.footer.grid(row=7, column=2)

   
  def asciihex(self):
    self.thex.delete(1.0, END)
    a = self.tascii.get(1.0, END)
    l = len(a)-1
    w = 0
    while l>w:
      ascii = a[w:w+1]
      ascii = b2a_hex(ascii).upper() + ' '
      self.thex.insert(END, ascii)
      w=w+1

  def hexascii(self):
    self.tascii.delete(1.0, END)
    r = self.thex.get(1.0, END)
    l = len(r)-1
    u = 0
    while l>u:
      ahex = r[u:u+2]
      ahex = a2b_hex(ahex)
      self.tascii.insert(END, ahex)
      u = u+3


root = Tk()
app = AsciiHex(root)
root.mainloop()
by Jillur Rahman

Jillur Rahman is a Web designers. He enjoys to make blogger templates. He always try to make modern and 3D looking Templates. You can by his templates from Themeforest.

Follow him @ Twitter | Facebook | Google Plus

by Rahman Surya Praja

Freelance Forever

Follow him @ Twitter | Facebook | Google Plus

1 komentar :

Terima Kasih Sudah berkunjung!! Di Mohon Untuk Meninggalkan Komen, untuk mempererat silaturahmi.... ^_^