IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

python R-S-A

IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码


import rsa from rsa import common, transform, core import os import base64 '''测试OK 参数中的密钥对privkey.d, privkey.n与pubkey.e, pubkey.n互换可实现: 公钥加密和私钥解密 私钥加密和公钥解密 (d,n 可计算出e) ''' class MyRSA_SupportPrivEncrypt(): def __init__(self): self.prikey_str = '''-----BEGIN RSA PRIVATE KEY----- MIICXwIBAAKBgQCCrkaLLCQqY+I45hSwmdtEb5RtjWlVFzclQfKnE3J0AARK8q5Y -----END RSA PRIVATE KEY----- ''' self.pubkey_str = '''-----BEGIN RSA PUBLIC KEY----- MIGJAoGBAIKuRossJCpj4jjmFLCZ20RvlG2NaVUXNyVB8qcTcnQABEryrlhgq1Ui -----END RSA PUBLIC KEY----- ''' self.key_private = rsa.PrivateKey.load_pkcs1(self.prikey_str) self.key_public = rsa.PublicKey.load_pkcs1(self.pubkey_str) # #======================加载密钥 start================ def setPrivateKeyStr(self, strPrikey): self.prikey_str = strPrikey def setPublicKeyStr(self, strPubkey): self.pubkey_str = strPubkey def readFilePrivateKeyStr(self, strPrikeyPathFile): with open(strPrikeyPathFile, 'r') as f: self.prikey_str = f.read() # print(self.prikey_str) def readFilePublicKeyStr(self, strPublicPathFile): with open(strPublicPathFile, 'r') as f: self.pubkey_str = f.read() def getPrivateKeyFromStr(self): self.key_private = rsa.PrivateKey.load_pkcs1(self.prikey_str) def getPublicKeyFromStr(self): self.key_public = rsa.PublicKey.load_pkcs1(self.pubkey_str) # ======================加载密钥 end================ def _pad_for_encryption(self, message, target_length): max_msglength = target_length - 11 msglength = len(message) if msglength > max_msglength: raise OverflowError( "%i bytes needed for message, but there is only" " space for %i" % (msglength, max_msglength) ) padding = b"" padding_length = target_length - msglength - 3 while len(padding) < padding_length: needed_bytes = padding_length - len(padding) new_padding = os.urandom(needed_bytes + 5) new_padding = new_padding.replace(b"\x00", b"") padding = padding + new_padding[:needed_bytes] assert len(padding) == padding_length return b"".join([b"\x00\x02", padding, b"\x00", message]) def create_KeyPare(self): # 生成公钥和私钥 (pubkey, privkey) = rsa.newkeys(1024) pub = pubkey.save_pkcs1() with open('public.pem', 'wb+')as f: f.write(pub) pri = privkey.save_pkcs1() with open('private.pem', 'wb+')as f: f.write(pri) def _encrypt(self, data: bytes, pubkey_e, pubkey_n): # 可换为prikey_d, prikey_n keylength = common.byte_size(pubkey_n) padded = self._pad_for_encryption(data, keylength) num = transform.bytes2int(padded) decrypto = core.encrypt_int(num, pubkey_e, pubkey_n) out = transform.int2bytes(decrypto) # print(out) return out def _decrypt(self, data: bytes, prikey_d, prikey_n): # 可换为pubkey_e, pubkey_n num = transform.bytes2int(data) decrypto = core.decrypt_int(num, prikey_d, prikey_n) out = transform.int2bytes(decrypto) sep_idx = out.index(b"\x00", 2) out = out[sep_idx + 1:] return out # =================== def longEncrypt_Base64_PriKey(self, data: bytes): # , privkey: rsa.PrivateKey length = len(data) keylength = common.byte_size(self.key_private.n) # print(keylength) default_length = keylength-11 # 长度不用分段 if length < default_length: return base64.b64encode(self._encrypt(data, self.key_private.d, self.key_private.n)) # 需要分段 offset = 0 res = [] while length - offset > 0: if length - offset > default_length: res.append(self._encrypt( data[offset:offset + default_length], self.key_private.d, self.key_private.n)) else: res.append(self._encrypt( data[offset:], self.key_private.d, self.key_private.n)) offset += default_length # print(res) byte_data = b''.join(res) #print(byte_data) return base64.b64encode(byte_data) def longDecrypt_Base64_PubKey(self, data: bytes): # , pubkey:rsa.PublicKey crypt_data = base64.b64decode(data) key_length = rsa.common.byte_size(self.key_public.n) if len(crypt_data) % key_length != 0: # 如果数据长度不是key_length的整数倍, 则数据是无效的 return None length = len(crypt_data) if length < key_length: return self._decrypt(crypt_data, self.key_public.e, self.key_public.n).decode('utf8') # 需要分段 offset = 0 res = [] while length - offset > 0: if length - offset > key_length: res.append(self._decrypt( crypt_data[offset:offset + key_length], self.key_public.e, self.key_public.n)) else: res.append(self._decrypt( crypt_data[offset:], self.key_public.e, self.key_public.n)) offset += key_length return b''.join(res).decode('utf8') if __name__ == '__main__': data = """ 光头强其实说起来,也是一个吃货,在这部动画片中,总是能听见光头强说,想吃这个想吃那个的。 只不过很多时候,因为经济的问题,光头强根本就吃不起,所以这也就练就了,光头强一身好厨艺。 不过更多的时候,光头强吃的,还是别人做的。那么,接下来的话,我们就来看看,光头强吃过的那些食物, 没想到这最贵的,竟然要上万元,不得不说,光头强真的是太豪气了。 泡面是光头强,除了馒头之外,吃的第二多的食物,选择泡面的缘故,一方面自然是因为便宜, 还有一方面就是,泡面只需要泡一泡就好了,十分节约时间。不过,这泡面吃多了之后,光头强对于泡面, 也是十分的讨厌。说起来,以前很多人小的时候,也总是喜欢吃泡面,可是长大之后,对于这种食物, 其实都挺抵触的。 牛肉面应该算光头强,为数不多吃的东西了,因为对于光头强来说,这牛肉面其实挺贵的,经常吃也吃不起。 而这个牛肉面的味道,自然是挺不错的,不然那个时候,光头强也不会因为这一碗牛肉面,就直接和赵琳吵了起来。 而且说起来,这牛肉面里的牛肉,看起来也是挺多的,光头强吃的时候,应该很开心吧。 """ data2b = data.encode('utf8') a = MyRSA_SupportPrivEncrypt() '''a.readFilePrivateKeyStr('private.pem') a.getPrivateKeyFromStr()''' pwd = a.longEncrypt_Base64_PriKey(data2b) #print (pwd) '''f = open('passwd.data', 'r') pwd=f.read() f.close()''' ddata = a.longDecrypt_Base64_PubKey(pwd) print(ddata)

文章永久链接:https://tech.souyunku.com/?p=42175


Warning: A non-numeric value encountered in /data/wangzhan/tech.souyunku.com.wp/wp-content/themes/dux/functions-theme.php on line 1154
赞(72) 打赏



未经允许不得转载:搜云库技术团队 » python R-S-A

IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码
IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

评论 抢沙发

大前端WP主题 更专业 更方便

联系我们联系我们

觉得文章有用就打赏一下文章作者

微信扫一扫打赏

微信扫一扫打赏


Fatal error: Uncaught Exception: Cache directory not writable. Comet Cache needs this directory please: `/data/wangzhan/tech.souyunku.com.wp/wp-content/cache/comet-cache/cache/https/tech-souyunku-com/index.q`. Set permissions to `755` or higher; `777` might be needed in some cases. in /data/wangzhan/tech.souyunku.com.wp/wp-content/plugins/comet-cache/src/includes/traits/Ac/ObUtils.php:367 Stack trace: #0 [internal function]: WebSharks\CometCache\Classes\AdvancedCache->outputBufferCallbackHandler() #1 /data/wangzhan/tech.souyunku.com.wp/wp-includes/functions.php(5109): ob_end_flush() #2 /data/wangzhan/tech.souyunku.com.wp/wp-includes/class-wp-hook.php(303): wp_ob_end_flush_all() #3 /data/wangzhan/tech.souyunku.com.wp/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters() #4 /data/wangzhan/tech.souyunku.com.wp/wp-includes/plugin.php(470): WP_Hook->do_action() #5 /data/wangzhan/tech.souyunku.com.wp/wp-includes/load.php(1097): do_action() #6 [internal function]: shutdown_action_hook() #7 {main} thrown in /data/wangzhan/tech.souyunku.com.wp/wp-content/plugins/comet-cache/src/includes/traits/Ac/ObUtils.php on line 367