本文整理汇总了Python中rsa.decrypt方法的典型用法代码示例。如果您正苦于以下问题:Python rsa.decrypt方法的具体用法?Python rsa.decrypt怎么用?Python rsa.decrypt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rsa
的用法示例。
在下文中一共展示了rsa.decrypt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pull_aes_key
# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import decrypt [as 别名]
def pull_aes_key():
def agreemnt_key(string):
send_data(string)
key_rsa = sock.recv(BUFSIZE)
return key_rsa
import rsa
AES_Key_RSA = agreemnt_key(b'ApplyKey')
with open('private.pem', 'r') as f:
priv_key = rsa.PrivateKey.load_pkcs1(f.read().encode())
AES_Key = rsa.decrypt(AES_Key_RSA, priv_key).decode('utf-8')
print('Obtaining Key Success!')
return AES_Key
# AES模块
示例2: accept_cfg
# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import decrypt [as 别名]
def accept_cfg():
Gud = ['pull_list']
Gud_str = '#'.join(Gud)
user_config_raw = accept_data(Gud_str)
user_config_temp = crytpion.decrypt(user_config_raw)
if user_config_temp != 'None':
print('Update user list')
try:
user_config_list = [eval(i) for i in user_config_temp.split("#")]
update_cfg(user_config_list, run_os)
print('Update OK!')
except Exception as e:
print(e)
print('Update Error!')
else:
print('Updates could not be found')
# 更新流量
示例3: update_traffic
# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import decrypt [as 别名]
def update_traffic():
Gud = ['push_traffic']
for user in User_list:
try:
traffic_msg = traffic_check(user['email'])
if traffic_msg != 0:
Gud.append([
int(user['email'][:-(len(DOMAIN) + 1)]), traffic_msg[0],
traffic_msg[1], traffic_msg[2]
])
except Exception as e:
print('ID:' + user['email'][:-(len(DOMAIN) + 1)] +
' Traffic read error!')
print(e)
Gud_str = '#'.join('%s' % i for i in Gud)
if crytpion.decrypt(accept_data(Gud_str)) == '$%^':
return
else:
pass
# 主函数
示例4: add_to_params
# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import decrypt [as 别名]
def add_to_params(self, parameters, value):
"""
This gets called with the value of our ``--priv-launch-key``
if it is specified. It needs to determine if the path
provided is valid and, if it is, it stores it in the instance
variable ``_key_path`` for use by the decrypt routine.
"""
if value:
path = os.path.expandvars(value)
path = os.path.expanduser(path)
if os.path.isfile(path):
self._key_path = path
endpoint_prefix = \
self._operation_model.service_model.endpoint_prefix
event = 'after-call.%s.%s' % (endpoint_prefix,
self._operation_model.name)
self._session.register(event, self._decrypt_password_data)
else:
msg = ('priv-launch-key should be a path to the '
'local SSH private key file used to launch '
'the instance.')
raise ValueError(msg)
示例5: decrypt_str
# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import decrypt [as 别名]
def decrypt_str(self, message):
"""
:param message:
:return: bytes
"""
msg = base64.b64decode(message)
length = len(msg)
default_length = self.default_length + 11
# 长度不用分段
if length < default_length:
return rsa.decrypt(msg, self.private_key)
# 需要分段
offset = 0
res = []
while length - offset > 0:
if length - offset > default_length:
res.append(rsa.decrypt(msg[offset:offset + default_length], self.private_key))
else:
res.append(rsa.decrypt(msg[offset:], self.private_key))
offset += default_length
return b''.join(res)
示例6: Check_Token
# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import decrypt [as 别名]
def Check_Token(self, token_crypto, ip, ua):
global re_dict
if str(token_crypto)[-4:-1] != "NQZ":
return "[-]token flag is error!"
else:
# with open('../project/Helper/privkey.pem','r') as f:
# privkey = rsa.PrivateKey.load_pkcs1(f.read().encode())
token_message = base64.b64decode(token_crypto[:-4])
# token_message = rsa.decrypt(token_crypto, privkey)
print("RSA解密后 ", token_message)
message = AES_Crypt_Cookies()
if message.Decrypt_Check_Token(token_message, ip, ua):
# token 校验成功,合法
re_dict["token_status"] = ReturnStatus.TOKEN_ERROR
else:
# token 校验失败,不合法
re_dict["token_status"] = ReturnStatus.TOKEN_SUCCESS
示例7: decodebytes
# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import decrypt [as 别名]
def decodebytes(self, text):
aes = self.aes()
return str(aes.decrypt(base64.decodebytes(bytes(
text, encoding='utf8'))).rstrip(b'\0').decode("utf8")) # 解密
示例8: rsaDecrypt
# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import decrypt [as 别名]
def rsaDecrypt(self, text):
"""
:param text:bytes
:return: str
"""
content = rsa.decrypt(text, self.privkey)
con = content.decode('utf-8')
return con
示例9: descrypt
# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import decrypt [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()
示例10: decrypt
# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import decrypt [as 别名]
def decrypt(self, text):
cryptor = DES3.new(self.key, self.mode)
plain_text = cryptor.decrypt(text)
st = str(plain_text.decode("utf-8")).rstrip('\0')
return st
示例11: decrypt
# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import decrypt [as 别名]
def decrypt(self, text):
cryptor = self.AES.new(self.key, self.mode, self.iv)
plain_text = cryptor.decrypt(self.a2b_hex(text))
return plain_text.rstrip(b'\0').decode()
示例12: decrypt
# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import decrypt [as 别名]
def decrypt(crypto):
message = rsa.decrypt(crypto, privkey)
return message
示例13: rsa_long_decrypt
# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import decrypt [as 别名]
def rsa_long_decrypt(self, crypto, length = 128):
res = []
for i in range(0, len(crypto), length):
res.append(rsa.decrypt(crypto[i : i + length], self.privkey))
return b"".join(res)
示例14: aes_decrypt
# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import decrypt [as 别名]
def aes_decrypt(self, encrypt):
return self.aes_encrypt(encrypt)
#aes_obj_enc = AES.new(self.aes, AES.MODE_CBC, self.iv)
#return aes_obj_enc.decrypt(encrypt).rstrip(PADDING)
示例15: perform_operation
# 需要导入模块: import rsa [as 别名]
# 或者: from rsa import decrypt [as 别名]
def perform_operation(self, indata, priv_key, cli_args=None):
"""Decrypts files."""
return rsa.decrypt(indata, priv_key)