![]() |
|
[python] Base64 encrypt & decrypt - Printable Version +- HN-Community (https://hacker-newbie.org) +-- Forum: Miscellaneous (https://hacker-newbie.org/forum-86.html) +--- Forum: Coding/Programing (https://hacker-newbie.org/forum-19.html) +---- Forum: Python (https://hacker-newbie.org/forum-81.html) +---- Thread: [python] Base64 encrypt & decrypt (/thread-9143.html) |
[python] Base64 encrypt & decrypt - h1t4k3 - 07-06-2011 coding python buat encrypt ama decrypt Base64 langsung cek this out *_* Code: #!/usr/bin/python
# work di python 2.x
# promina.py
import os, sys
from base64 import standard_b64encode, standard_b64decode
#bersih-bersih :v
if sys.platform == 'linux-i386' or sys.platform == 'darwin' or sys.platform == 'linux2':
sysCommand = 'clear'
elif sys.platform == 'win32' or sys.platform == 'ms-dos' or sys.platform == 'dos':
sysCommand = 'cls'
else:
sysCommand = 'jancok'
#input
def promina() :
os.system(sysCommand)
print '|===================|'
print ' '
print '\n1. Base64 Decrypt '
print '\n2. Base64 Encrypt '
print '\n3. Keluar '
print ' '
print '|===================|'
Masuk = raw_input('\n\nMasukan Pilihan: ')
if (Masuk == '1'):
prenagen()
elif (Masuk == '2'):
sule()
elif (Masuk == '3'):
os.system(sysCommand)
sys.exit(1)
else:
Promina()
#encode
def sule() :
os.system(sysCommand)
masuk = raw_input("\nMasukan string: ")
try:
crut = standard_b64encode(masuk)
print '\n',masuk,' = ',crut
print ' '
file = open("sementara.txt", "a")
file.write(crut)
file.close()
except:
os.system(sysCommand)
print 'ITU NGGAK BISA SETAN !!!'
sys.exit()
simpan = raw_input('Simpan hasil encode ? (y/n) : ')
os.system(sysCommand)
if (simpan == 'y'):
f = open("encode.txt", "a+")
f.write("\n")
f.write(standard_b64encode(masuk))
f.close
os.system(sysCommand)
print '\nfile disimpan di encode.txt'
elif (simpan == 'n'):
sys.exit()
else :
os.system(sysCommand)
print 'JANCOK,MASUKIN PILIHAN YANG ADA !!!'
prikitiw()
#Decode
def prenagen() :
os.system(sysCommand)
masuk = raw_input("\nMasukan string : ")
try:
hasil = standard_b64decode(masuk)
print '\n',masuk,' = ',hasil
print ' '
file = open("sementawis.txt", "a")
file.write(hasil)
file.close()
except:
print 'ITU NGGAK BISA SETAN!!!'
sys.exit()
nyimpan = raw_input('Simpan hasil Decode ? (y/n) : ')
os.system(sysCommand)
if (nyimpan == 'y'):
f = open("decode.txt", "a+")
f.write("\n")
f.write(standard_b64decode(masuk))
f.close
os.system(sysCommand)
print '\nfile berhasil disimpan di decoded.txt'
elif (nyimpan == 'n'):
sys.exit()
else:
os.system(sysCommand)
print 'JANCOK,MASUKIN PILIHAN YANG ADA !!!'
prakataw()
#ulangi encode
def prikitiw() :
masuk = raw_input('\nUlang Lagi? (y/n) : ')
if (masuk == 'y'):
sule()
elif (masuk == 'n'):
promina()
else:
prikitiw()
#ulangi decode
def prakataw() :
masuk = raw_input('\nUlang Lagi? (y/n) : ')
if (masuk == 'y'):
prenagen()
elif (masuk == 'n'):
promina()
else:
prakataw()
promina()Code: python promina.pySekian *_* RE: [python] Base64 encrypt & decrypt - Dika_xb - 07-07-2011 HN coder ![]() kwkw mantab bro kalo di php lebih mudah tinggal <?php echo base64_encode('text yg mau di encode'); ?> mantab lah bro untuk pembelajaran
RE: [python] Base64 encrypt & decrypt - h1t4k3 - 07-07-2011 (07-07-2011, 12:18 AM)Dika_xb Wrote: HN coder ini juga intinya cuman ini doang kok ![]() crut = standard_b64encode(masuk) <<<=== encode hasil = standard_b64decode(masuk) <<<<=== decode masih tahap belajar bro ![]() RE: [python] Base64 encrypt & decrypt - NeutronX - 07-07-2011 nyoba nyicip ah ![]() share nya lumayan buat pemula kaya gw
RE: [python] Base64 encrypt & decrypt - h1t4k3 - 07-07-2011 (07-07-2011, 06:17 PM)NeutronX Wrote: nyoba nyicip ah Silahkan bro
|