【python暗号解読】pythonの暗号解読モジュール使用
2754 ワード
# encoding: utf-8
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
#######################Base64 ( )###################
# Base64 ,64 A-Z、a-z、0-9、+ / 64 , “=” ,
import base64
### #########
s1 = base64.encodestring('hello world')
### ################
s2 = base64.decodestring(s1)
print s1, s2
#####################MD5 ( )########################
# md5
import hashlib
# key 。
hash = hashlib.md5('allaigapfg')
############### ################
hash.update('hello world')
print hash.hexdigest()
###########################RSA ################################
import rsa
(bob_pub, bob_priv) = rsa.newkeys(512)
message = 'hello world'
crypto = rsa.encrypt(message, bob_pub)
message = rsa.decrypt(crypto, bob_priv)
print message
"D:\Program Files\Python27\python.exe" D:/PycharmProjects/learn2017/ .py
aGVsbG8gd29ybGQ=
hello world
df598ab7b545791dc287bdfc3cea9fe6
hello world
Process finished with exit code 0