本文整理汇总了Python中pyDes.des函数的典型用法代码示例。如果您正苦于以下问题:Python des函数的具体用法?Python des怎么用?Python des使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了des函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: digest
def digest (password):
"""This method returns the LM hash of a password in a binary string.
@param password The password to calculate the LM hash.
@return A binary string with the LM value"""
# Get the PASSWORD (uppercase)
upperPass = password.upper()
# Get a list with each character of upperPass in hex format
mPass = map(hex,map(ord,upperPass))
# Pad with NULLs
mPass.extend (['0x00']*(14-len(mPass)))
# Split in 2 7-bytes parts and get the 2 related keys
key1 = __getKey ( ['0x00'] + mPass[:7] )
key2 = __getKey ( ['0x00'] + mPass[7:14] )
# Get the LM hash
BASESTRING = '[email protected]#$%'
des = pyDes.des ( key1, mode=pyDes.ECB, pad='\x00' )
lmhash = des.encrypt( BASESTRING )
des = pyDes.des ( key2, mode=pyDes.ECB, pad='\x00' )
lmhash += des.encrypt( BASESTRING )
# Return the LM hash
return lmhash
开发者ID:JulGor,项目名称:Cryptography,代码行数:30,代码来源:lm.py
示例2: encrypt
def encrypt(text):
if isinstance(text, str) == False:
raise TypeError
key = generateKey()
text = DecryptionIdentifier + text
des = pyDes.des(key, padmode = pyDes.PAD_PKCS5)
return des.encrypt(text)
开发者ID:153370771,项目名称:ZJUWLAN_AUTO_LOGIN,代码行数:7,代码来源:main.py
示例3: decrypt
def decrypt(cipherHex, db_system_id):
cipherText = binascii.unhexlify(cipherHex)
assert cipherText[0] == 5
key = cipherText[1:9]
cipher = pyDes.des(key, mode=pyDes.CBC, IV='\0' * 8, padmode=pyDes.PAD_PKCS5)
plainText = cipher.decrypt(cipherText[9:]).decode('utf-8')
return plainText
开发者ID:HugoShamrock,项目名称:sqldeveloper-parser,代码行数:7,代码来源:decryptor_3.py
示例4: crypt
def crypt(key, data, method):
cipher = pyDes.des(key, padmode=pyDes.PAD_PKCS5)
if method == 'e':
value = cipher.encrypt(data).encode('hex')
if method == 'd':
value = cipher.decrypt(data.decode('hex'))
return value
开发者ID:Nagasaki45,项目名称:SimpleCrypt,代码行数:7,代码来源:main.py
示例5: get_ep
def get_ep(fileid, sid, token):
src = sid+'_'+fileid+'_'+token
k=pyDes.des('bf09f477', pyDes.ECB, "\0\0\0\0\0\0\0\0", pad='\0', padmode=pyDes.PAD_NORMAL)
print src
d = k.encrypt(str(src))
ep = base64.b64encode(d)
return urllib.quote_plus(ep)
开发者ID:tuling56,项目名称:Python,代码行数:7,代码来源:down_video.py
示例6: change_unix_pwd
def change_unix_pwd(self):
"""Change password at unix level after password expiration at website
Level.Uses secret passphrase, old password and new password while
changing password.Returns True on success and False on failure.Also,
logs the error message incase of failure.
"""
old_pwd = self.config['COMMON.OLD_PASSWORD']
new_pwd = self.config['COMMON.PASSWORD']
home = self.config['COMMON.DEFAULT_HOME']
enc_pwd_file = self.config['COMMON.ENC_PASS_FILE']
secret_pphrase = self.config['pass_phrase']
if old_pwd == new_pwd:
self.data['UNIX_MSG'] = "Password change failed : old pwd = new pwd"
return False
try:
key = pyDes.des(secret_pphrase, pad=None, padmode=PAD_PKCS5)
enc_pwd = key.encrypt(new_pwd)
enc_file_loc = home + '/' + enc_pwd_file
fhandle = open(enc_file_loc, "w")
fhandle.write(enc_pwd)
except IOError, err:
logger.error("Password change failed :ERROR: "+str(err))
return False
开发者ID:libvenus,项目名称:Python_App_Validation_Automation,代码行数:26,代码来源:unix.py
示例7: encode
def encode(str):
if type(str) == types.UnicodeType:
str = str.encode("utf-8")
key = pyDes.des("12312312", pyDes.CBC, "12312312", pad=None, padmode=pyDes.PAD_PKCS5)
des_data = key.encrypt(str)
b_data = base64.b64encode(des_data)
return b_data
开发者ID:niyoufa,项目名称:spider,代码行数:7,代码来源:wslib.py
示例8: __desencrypt
def __desencrypt(self, data, key):
""" DES encrypt algorithm, to generate signature. """
ph = '--------'
key = (key + ph)[:8] # 8 digits
des = pyDes.des(key, pyDes.CBC, key, pad=None, padmode=pyDes.PAD_PKCS5)
d = des.encrypt(data)
return binascii.hexlify(d)
开发者ID:gitaloha,项目名称:mp-tornado,代码行数:7,代码来源:tencent_passport.py
示例9: decryptFile
def decryptFile(inputFilePath, outputFilePath):
file = open(inputFilePath)
data = file.read()
k = pyDes.des("DESCRYPT", pyDes.CBC, "\0\0\0\0\0\0\0\0", pad=None, padmode=pyDes.PAD_PKCS5)
decrypted_content = k.decrypt(data)
with open(outputFilePath, 'w') as file_handle:
file_handle.write(decrypted_content)
开发者ID:nirajdewani,项目名称:IBM-Bluemix-Object-Storage-based-Storage-as-a-Service.,代码行数:7,代码来源:cloudDrive.py
示例10: tweet
def tweet(request):
import base64
import pyDes
import re
import json
api = create_api(request)
tweet = request.GET["tweet"]
tweetbin = base64.b64decode(tweet)
k = pyDes.des(request.session.session_key[:8], pyDes.ECB)
tweetdec = k.decrypt(tweetbin)
tweetrep = re.compile("\x05*$").sub("", tweetdec)
content_type = "application/json;charset=UTF-8"
try:
api.status_update(tweetrep)
pass
except:
result = {"result": "fail"}
response = django.http.HttpResponseServerError(content=json.dumps(result), content_type=content_type)
else:
result = {"result": "success"}
response = django.http.HttpResponse(content=json.dumps(result), content_type=content_type)
return response
开发者ID:sowcod,项目名称:tPostman,代码行数:26,代码来源:api.py
示例11: get_sid_token
def get_sid_token(encrypt_string):
k=pyDes.des('e5571054', pyDes.ECB, "\0\0\0\0\0\0\0\0", pad='\32', padmode=pyDes.PAD_NORMAL)
enh=base64.decodestring(encrypt_string)
data = k.decrypt(enh)
data = data.split('\0')[0]
print data
return data
开发者ID:tuling56,项目名称:Python,代码行数:7,代码来源:down_video.py
示例12: read_pm25
def read_pm25():
service = RemotingService(config.AMF_GATEWAY).getService('FlashRemotingServiceLibrary.Sample.getSurvyValue')
extract = lambda s: int(s[8: s.find(u'微克')]) if s[9] != u'—' else None
key = pyDes.des(config.DES_KEY, pyDes.CBC, config.DES_IV)
return map(extract,
[key.decrypt(b64decode(service("PM25", scode))).decode("UTF-8")
for scode in config.STATION.iterkeys()]
) # I'm too lazy...
开发者ID:clippit,项目名称:NanjingAir,代码行数:8,代码来源:main.py
示例13: acctDecrypt
def acctDecrypt(AcctArray, pwkey):
#decrypt accounts
d = pyDes.des(pwkey)
for acct in AcctArray:
acct[1] = d.decrypt(acct[1],' ')
acct[3] = d.decrypt(acct[3],' ')
acct[4] = d.decrypt(acct[4],' ')
return AcctArray
开发者ID:NolanT,项目名称:ynab-qfx,代码行数:8,代码来源:control2.py
示例14: CalcMac3DES
def CalcMac3DES(data,initdata,key):
datalen = len(data)
k = pyDes.des(key[:8],pad=None, padmode=pyDes.PAD_NORMAL)
for i in range(datalen/8):
m = ""
for j in range(len(initdata)):
m = m + chr(ord(initdata[j]) ^ ord(data[i*8+j]))
initdata = m
x = k.encrypt(initdata)
initdata = x
k1 = pyDes.des(key[8:],pad=None, padmode=pyDes.PAD_NORMAL)
n = k1.decrypt(initdata)
initdata = k.encrypt(n)
return initdata
开发者ID:Codiscope-Research,项目名称:ykt4sungard,代码行数:18,代码来源:pbocfunc.py
示例15: encrypt
def encrypt(self, data):
k = pyDes.des(self.key, pyDes.CBC, self.iv, pad=None, padmode=pyDes.PAD_PKCS5)
d = k.encrypt(data)
print("xxxxoriginxxxxxxxxxx")
print(d)
print('...............................')
print "Encrypt00000000000000000ed:%r" % binascii.hexlify(d)
#d = base64.encodestring(d)
return d
开发者ID:tom31203120,项目名称:python_code,代码行数:9,代码来源:des-test.py
示例16: __init__
def __init__(self, IV):
'''
:param IV: initial value, length must be 8 bytes
'''
assert isinstance(IV, str)
assert len(IV) == 8
self.IV = IV
self.des = pyDes.des("DESCRYPT", pyDes.CBC, self.IV, pad=None, padmode=pyDes.PAD_PKCS5)
开发者ID:zhaoxiaoyuan,项目名称:CloudBackup,代码行数:10,代码来源:crypto.py
示例17: decryptKey
def decryptKey():
key='1122334455667788'
data='5B4A94494D94CCAEB823A0302D789E5DA0EE5C28AF05D1354EFF59C3C3EDD44A'
data2='3CF5F19CFE622E70D1BBF719A6D29CCE229A3AB5C502C90C37EC16E8C7962B53'
k = pyDes.des(codecs.decode(key,'hex'), pad=None, padmode=pyDes.PAD_NORMAL)
e = k.decrypt(codecs.decode(data,'hex'))
print 'load key[%s]' % codecs.encode(e,'hex')
e = k.decrypt(codecs.decode(data2,'hex'))
print 'main key[%s]' % codecs.encode(e,'hex')
开发者ID:nykma,项目名称:ykt4sungard,代码行数:10,代码来源:test_mfkey.py
示例18: decrypt
def decrypt(cipher):
key = generateKey()
des = pyDes.des(key)
dcyIDLen = len(DecryptionIdentifier)
text = des.decrypt(cipher, padmode = pyDes.PAD_PKCS5)
if len(text) < dcyIDLen or text[0:dcyIDLen] != DecryptionIdentifier:
raise DecryptionError
else:
text = text[dcyIDLen:]
return text
开发者ID:153370771,项目名称:ZJUWLAN_AUTO_LOGIN,代码行数:10,代码来源:main.py
示例19: encrypt
def encrypt(encrypt_str):
'''加密字符串'''
key="llgmgpyw"
k=pyDes.des(key,pyDes.CBC,"\0\0\0\0\0\0\0\0",pad=None,padmode=pyDes.PAD_PKCS5)
encrypt_str=encrypt_str.encode("base64")
ret=k.encrypt(encrypt_str)
ret=ret.encode("base64")
if ret[-1:]=="\n":
ret=ret[:-1]
return ret
开发者ID:SongJLG,项目名称:johan-doc,代码行数:10,代码来源:authorize_fun.py
示例20: decipher_bloomberg_file
def decipher_bloomberg_file(key_as_str, in_filename, out_filename):
# Instanciate the DES decryptor
decrypt = des(str(des_string_to_key(key_as_str)),CBC,BLOOMBERG_PADDING, pad=None, padmode=PAD_NORMAL)
in_file = open(in_filename,'rb')
uubuffer = in_file.read()
in_file.close()
out_file = open(out_filename,'wb')
uudecode = codecs.getdecoder('uu')
payload, size = uudecode(uubuffer)
out_file.write(decrypt.decrypt(payload))
out_file.close()
开发者ID:humblejok,项目名称:jok_des_tools,代码行数:11,代码来源:des_tools.py
注:本文中的pyDes.des函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论