Python rsa 模块,encrypt() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用rsa.encrypt()

项目:weibo    作者:windskyer    | 项目源码 | 文件源码
def get_pwd_rsa(self, pwd, servertime, nonce):
        """
            Get rsa2 encrypted password, using RSA module from https://pypi.python.org/pypi/rsa/3.1.1, documents can be accessed at
            http://stuvel.eu/files/python-rsa-doc/index.html
        """
        #n, n parameter of RSA public key, which is published by WEIBO.COM
        #hardcoded here but you can also find it from values return from prelogin status above
        weibo_rsa_n = 'EB2A38568661887FA180BDDB5CABD5F21C7BFD59C090CB2D245A87AC253062882729293E5506350508E7F9AA3BB77F4333231490F915F6D63C55FE2F08A49B353F444AD3993CACC02DB784ABBB8E42A9B1BBFFFB38BE18D78E87A0E41B9B8F73A928EE0CCEE1F6739884B9777E4FE9E88A1BBE495927AC4A799B3181D6442443'

        #e, exponent parameter of RSA public key, WEIBO uses 0x10001, which is 65537 in Decimal
        weibo_rsa_e = 65537
        message = str(servertime) + '\t' + str(nonce) + '\n' + str(pwd)

        #construct WEIBO RSA Publickey using n and e above, note that n is a hex string
        key = rsa.PublicKey(int(weibo_rsa_n, 16), weibo_rsa_e)

        #get encrypted password
        encropy_pwd = rsa.encrypt(message, key)
        #trun back encrypted password binaries to hex string
        return binascii.b2a_hex(encropy_pwd)
项目:weiboapi    作者:lawRossi    | 项目源码 | 文件源码
def encrypt_password(p, st, nonce, pk, rsakv):
    """
    Encrypting the password using rsa algorithm.
    p: password
    st: server time
    nonce: random value
    pk: public key
    rsakv: rsa key value
    """
    pk = '0x' + pk
    pk = int(pk, 16)
    msg = str(st) + '\t' + str(nonce) + '\n' + p
    key = rsa.PublicKey(pk, 65537)
    psw = rsa.encrypt(msg.encode("utf-8"), key)
    psw = binascii.b2a_hex(psw)
    return decode(psw)
项目:fuck-login    作者:xchaoinfo    | 项目源码 | 文件源码
def getPublicKey():
    login_public_key_url = 'https://lantouzi.com/api/uc/get_key?%s' % time.time()
    # ?????
    headers = {'Referer': 'https://lantouzi.com/login'}
    data = session.get(login_public_key_url, headers=headers).content.decode('utf-8')
    # print(data)
    # data = "{'data': {'encrypt': {'field_name': '_encrypt_code', 'public_key': '-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDidnLFl8ivfrAtKz9YX0Qi1V4b\nq/x4lHDjswf9AQS8hzfxsbzzDaDa07V7N6PvibJYqbhrj14Pi2fGC7CED5MzQ1r6\nvwmT+wJeBC//8PVxZXo/h15g2QzfYkyp4z+IlJZYqHfYGZXu9HTsFDZhfQE8LEz3\nkbAfyb2sLcfGimQWRwIDAQAB\n-----END PUBLIC KEY-----\n', 'field_value': '480b74ab3a165ef8bf2685a0d56f6b7a'}}, 'code': 1, 'message': ''}"
    try:
        data = json.loads(data)
        if data['code'] == 1:
            return data['data']['encrypt']
        return False
    except:
        return False


# ?????
项目:baidutongji    作者:yelord    | 项目源码 | 文件源码
def encrypt(data):
    # load?????
    with open('api_pub.key') as publickfile:
        p = publickfile.read()
        pubkey = rsa.PublicKey.load_pkcs1_openssl_pem(p)

    # ?????
    n = int(math.ceil(len(data) * 1.0 / 117))
    ret = ''
    for i in range(n):
        gzdata = data[i * 117:(i + 1) * 117]
        ret += rsa.encrypt(gzdata, pubkey)

    # print ret
    return ret


# ??gzip
项目:baidutongji    作者:yelord    | 项目源码 | 文件源码
def prelogin(self):
        data = {'username': self.username,
                'token': self.token,
                'functionName': 'preLogin',
                'uuid': UUID,
                'request': {'osVersion': 'windows', 'deviceType': 'pc', 'clientVersion': '1.0'},
                }

        headers = {'UUID': UUID, 'account_type': ACCOUNT_TYPE,
                   'Content-Type': 'data/gzencode and rsa public encrypt;charset=UTF-8'
                   }

        # ??
        post_data = gzencode(json.dumps(data))
        # ??
        post_data = encrypt(post_data)

        resp = requests.post(LOGIN_URL, data=post_data, headers=headers)
        ret = json.loads(gzdecode(resp.content[8:]))
        print 'prelogin:', ret
项目:baidutongji    作者:yelord    | 项目源码 | 文件源码
def dologin(self):
        data = {'username': self.username,
                'token': self.token,
                'functionName': 'doLogin',
                'uuid': UUID,
                'request': {'password': self.password}
                }

        headers = {'UUID': UUID, 'account_type': ACCOUNT_TYPE,
                   'Content-Type': 'data/gzencode and rsa public encrypt;charset=UTF-8'
                   }

        # ??
        post_data = gzencode(json.dumps(data))
        # ??
        post_data = encrypt(post_data)
        # post
        resp = requests.post(LOGIN_URL, data=post_data, headers=headers)
        ret = json.loads(gzdecode(resp.content[8:]))
        if ret['retcode'] == 0:
            print u'dologin:', ret['retmsg']
            print ret['ucid']
            print ret['st']
        return ret
项目:baidutongji    作者:yelord    | 项目源码 | 文件源码
def dologout(self):
        data = {'username': self.username,
                'token': self.token,
                'functionName': 'doLogout',
                'uuid': UUID,
                'request': {'ucid': self.ucid, 'st': self.st, }
                }

        headers = {'UUID': UUID, 'account_type': ACCOUNT_TYPE,
                   'Content-Type': 'data/gzencode and rsa public encrypt;charset=UTF-8'
                   }

        # ??
        post_data = gzencode(json.dumps(data))
        # ??
        post_data = encrypt(post_data)
        # post
        resp = requests.post(LOGIN_URL, data=post_data, headers=headers)
        ret = json.loads(gzdecode(resp.content[8:]))
        print 'logout:', ret['retmsg']
项目:rsplus    作者:zoxuyu    | 项目源码 | 文件源码
def encrypt_assistant():
    fname = input("Bitte gebe den Pfad der zu verschlüsselnden Datei an: ")
    f = open(fname, "rb")
    content = f.read()
    f.close()
    print("Datei eingelesen.")
    names = pubkr.gets()
    print("Namen: " + ' '.join(names))
    name = input("Bitte wähle einen aus: ")
    while not name in names:
        if name == "": return
        print("Dieser Name existiert nicht.")
        print("Namen: " + ' '.join(names))
        name = input("Bitte wähle einen anderen aus: ")
    print("Verschlüssele (dauert einen Moment)")
    crypt = rsa.encrypt(content, pubkr.get(name))
    crypt = str(base64.b64encode(bytes(crypt, "utf-8")), "utf-8")
    crypt = insert_newlines(crypt, 60)
    crypt = armor("RSPLUS OUTPUT", name, crypt)
    f = open(fname + ".crypt", "w")
    f.write(crypt)
    f.close()

    print("Die verschlüsselte Version der Datei können sie unter " + fname +  ".crypt finden. Sie können diese Datei an den Empfänger versenden.")
项目:rsplus    作者:zoxuyu    | 项目源码 | 文件源码
def encrypt_assistant():
    fname = input("Bitte gebe den Pfad der zu verschlüsselnden Datei an: ")
    f = open(fname, "rb")
    content = f.read()
    f.close()
    print("Datei eingelesen.")
    names = pubkr.gets()
    print("Namen: " + ' '.join(names))
    name = input("Bitte wähle einen aus: ")
    while not name in names:
        if name == "": return
        print("Dieser Name existiert nicht.")
        print("Namen: " + ' '.join(names))
        name = input("Bitte wähle einen anderen aus: ")
    print("Verschlüssele (dauert einen Moment)")
    crypt = rsa.encrypt(content, pubkr.get(name))
    crypt = str(base64.b64encode(bytes(crypt, "utf-8")), "utf-8")
    crypt = insert_newlines(crypt, 60)
    crypt = armor("RSPLUS OUTPUT", name, crypt)
    f = open(fname + ".crypt", "w")
    f.write(crypt)
    f.close()

    print("Die verschlüsselte Version der Datei können sie unter " + fname +  ".crypt finden. Sie können diese Datei an den Empfänger versenden.")
项目:flora    作者:Lamden    | 项目源码 | 文件源码
def get(self):
        # checks if the user can create a new package entry
        # if so, returns a new secret
        # user then must post the signed package to this endpoint
        if not ENGINE.check_package(request.form['owner'], request.form['package']):
            # try to pull the users public key
            query = ENGINE.get_key(request.form['owner'])

            # in doing so, check if the user exists
            if query == None:
                return error_payload('Owner does not exist.')

            # construct the user's public key
            user_public_key = rsa.PublicKey(int(query[0]), int(query[1]))

            # create a new secret
            secret = random_string(53)

            # sign and store it in the db so no plain text instance exists in the universe
            server_signed_secret = str(rsa.encrypt(secret.encode('utf8'), KEY[0]))
            query = ENGINE.set_secret(request.form['owner'], server_signed_secret)

            # sign and send secret to user
            user_signed_secret = rsa.encrypt(secret.encode('utf8'), user_public_key)
            return success_payload(str(user_signed_secret), 'Package available to register.')

        else:
            return error_payload('Package already exists.')
项目:sinal2    作者:observerss    | 项目源码 | 文件源码
def encrypt_passwd(self, passwd, pubkey, servertime, nonce):
        key = rsa.PublicKey(int(pubkey, 16), int('10001', 16))
        message = str(servertime) + '\t' + str(nonce) + '\n' + str(passwd)
        passwd = rsa.encrypt(message.encode('utf-8'), key)
        return binascii.b2a_hex(passwd)
项目:oscars2016    作者:0x0ece    | 项目源码 | 文件源码
def perform_operation(self, indata, pub_key, cli_args=None):
        '''Encrypts files.'''

        return rsa.encrypt(indata, pub_key)
项目:GAMADV-XTD    作者:taers232c    | 项目源码 | 文件源码
def perform_operation(self, indata, pub_key, cli_args=None):
        """Encrypts files."""

        return rsa.encrypt(indata, pub_key)
项目:zeronet-debian    作者:bashrc    | 项目源码 | 文件源码
def perform_operation(self, indata, pub_key, cli_args=None):
        '''Encrypts files.'''

        return rsa.encrypt(indata, pub_key)
项目:Telethon    作者:LonamiWebs    | 项目源码 | 文件源码
def encrypt(fingerprint, data):
    """
    Encrypts the given data known the fingerprint to be used
    in the way Telegram requires us to do so (sha1(data) + data + padding)

    :param fingerprint: the fingerprint of the RSA key.
    :param data: the data to be encrypted.
    :return:
        the cipher text, or None if no key matching this fingerprint is found.
    """
    global _server_keys
    key = _server_keys.get(fingerprint, None)
    if not key:
        return None

    # len(sha1.digest) is always 20, so we're left with 255 - 20 - x padding
    to_encrypt = sha1(data).digest() + data + os.urandom(235 - len(data))

    # rsa module rsa.encrypt adds 11 bits for padding which we don't want
    # rsa module uses rsa.transform.bytes2int(to_encrypt), easier way:
    payload = int.from_bytes(to_encrypt, 'big')
    encrypted = rsa.core.encrypt_int(payload, key.e, key.n)
    # rsa module uses transform.int2bytes(encrypted, keylength), easier:
    block = encrypted.to_bytes(256, 'big')
    return block


# Add default keys
项目:weibo    作者:windskyer    | 项目源码 | 文件源码
def get_pwd_rsa(self, pwd, servertime, nonce):
        """
        Get rsa2 encrypted password,
        using RSA module from https://pypi.python.org/pypi/rsa/3.1.1,
        documents can be accessed at
        http://stuvel.eu/files/python-rsa-doc/index.html
        """

        # n, n parameter of RSA public key,
        # which is published by WEIBO.COM
        # hardcoded here but you can also find
        # it from values return from prelogin status above

        weibo_rsa_n = ('EB2A38568661887FA180BDDB5CABD5F21C7BFD59C090'
                       'CB2D245A87AC253062882729293E5506350508E7F9AA'
                       '3BB77F4333231490F915F6D63C55FE2F08A49B353F44'
                       '4AD3993CACC02DB784ABBB8E42A9B1BBFFFB38BE18D7'
                       '8E87A0E41B9B8F73A928EE0CCEE1F6739884B9777E4F'
                       'E9E88A1BBE495927AC4A799B3181D6442443')

        # e, exponent parameter of RSA public key,
        # WEIBO uses 0x10001, which is 65537 in Decimal
        weibo_rsa_e = 65537
        message = str(servertime) + '\t' + str(nonce) + '\n' + str(pwd)

        # construct WEIBO RSA Publickey using n and e above,
        # note that n is a hex string
        key = rsa.PublicKey(int(weibo_rsa_n, 16), weibo_rsa_e)

        # get encrypted password
        if six.PY3:
            message = message.encode()

        encropy_pwd = rsa.encrypt(message, key)
        # trun back encrypted password binaries to hex string
        sp = binascii.b2a_hex(encropy_pwd)
        if six.PY3:
            sp = sp.decode('utf-8')

        return sp
项目:weibo    作者:windskyer    | 项目源码 | 文件源码
def get_pwd_rsa(self, pwd, servertime, nonce):
        """
            Get rsa2 encrypted password, using RSA module from https://pypi.python.org/pypi/rsa/3.1.1, documents can be accessed at
            http://stuvel.eu/files/python-rsa-doc/index.html
        """
        # n, n parameter of RSA public key, which is published by WEIBO.COM
        #hardcoded here but you can also find it from values return from prelogin status above
        #import pdb;pdb.set_trace()
        weibo_rsa_n = 'EB2A38568661887FA180BDDB5CABD5F21C7BFD59C090CB2D245A87AC253062882729293E5506350508E7F9AA3BB77F4333231490F915F6D63C55FE2F08A49B353F444AD3993CACC02DB784ABBB8E42A9B1BBFFFB38BE18D78E87A0E41B9B8F73A928EE0CCEE1F6739884B9777E4FE9E88A1BBE495927AC4A799B3181D6442443'

        #e, exponent parameter of RSA public key, WEIBO uses 0x10001, which is 65537 in Decimal
        weibo_rsa_e = 65537
        message = str(servertime) + '\t' + str(nonce) + '\n' + str(pwd)

        #construct WEIBO RSA Publickey using n and e above, note that n is a hex string
        key = rsa.PublicKey(int(weibo_rsa_n, 16), weibo_rsa_e)

        #get encrypted password
        if six.PY3:
            message = message.encode()
        encropy_pwd = rsa.encrypt(message, key)
        #trun back encrypted password binaries to hex string
        sp = binascii.b2a_hex(encropy_pwd)
        if six.PY3:
            sp = sp.decode('utf-8')
        return sp
项目:plugin.video.bdyun    作者:caasiu    | 项目源码 | 文件源码
def perform_operation(self, indata, pub_key, cli_args=None):
        """Encrypts files."""

        return rsa.encrypt(indata, pub_key)
项目:plugin.video.bdyun    作者:caasiu    | 项目源码 | 文件源码
def RSA_encrypt(public_key, message):
    rsakey = rsa.PublicKey.load_pkcs1_openssl_pem(public_key)
    encrypted = rsa.encrypt(message.encode('utf-8'), rsakey)
    return base64.encodestring(encrypted).decode('utf-8').replace('\n', '')
项目:SinaMicroblog_Creeper-Spider_VerificationCode    作者:somethingx64    | 项目源码 | 文件源码
def get_pwd(password, servertime, nonce, pubkey):
    rsaPublickey = int(pubkey, 16)
    key = rsa.PublicKey(rsaPublickey,65537)#create public key
    message = str(servertime) + '\t' + str(nonce) + '\n' + str(password)#create clear text
    passwd = rsa.encrypt(message, key)#cipher text
    passwd = binascii.b2a_hex(passwd)#convert the cipher text into hexadecimal
    return passwd
项目:WeiboPictureWorkflow    作者:cielpy    | 项目源码 | 文件源码
def perform_operation(self, indata, pub_key, cli_args=None):
        """Encrypts files."""

        return rsa.encrypt(indata, pub_key)
项目:WeiboPictureWorkflow    作者:cielpy    | 项目源码 | 文件源码
def generate_form_data(nonce, pubkey, servertime, rsakv, username, password):
    rsa_public_key = int(pubkey, 16)
    key = rsa.PublicKey(rsa_public_key, 65537)
    message = str(servertime) + '\t' + str(nonce) + '\n' + str(password)
    passwd = rsa.encrypt(message, key)
    passwd = binascii.b2a_hex(passwd)
    username = urllib2.quote(username)
    username = base64.encodestring(username)
    form_data = {
        'entry': 'weibo',
        'gateway': '1',
        'from': '',
        'savestate': '7',
        'useticket': '1',
        'pagerefer': 'http://weibo.com/p/1005052679342531/home?from=page_100505&mod=TAB&pids=plc_main',
        'vsnf': '1',
        'su': username,
        'service': 'miniblog',
        'servertime': servertime,
        'nonce': nonce,
        'pwencode': 'rsa2',
        'rsakv': rsakv,
        'sp': passwd,
        'sr': '1366*768',
        'encoding': 'UTF-8',
        'prelt': '115',
        'url': 'http://weibo.com/ajaxlogin.php?framelogin=1&callback=parent.sinaSSOController.feedBackUrlCallBack',
        'returntype': 'META'
    }
    form_data = urllib.urlencode(form_data)
    return form_data

# ====================?????cookie====================
项目:Fuck_Login    作者:devzhan    | 项目源码 | 文件源码
def rsaEncrypt(password):
    url = 'http://passport.bilibili.com/login?act=getkey'
    try:
        getKeyRes = session.get(url)
        token = json.loads(getKeyRes.content.decode('utf-8'))
        pw = str(token['hash'] + password).encode('utf-8')

        key = token['key']
        key = rsa.PublicKey.load_pkcs1_openssl_pem(key)

        pw = rsa.encrypt(pw, key)
        password = binascii.b2a_base64(pw)
        return password
    except:
        return False
项目:AshsSDK    作者:thehappydinoa    | 项目源码 | 文件源码
def perform_operation(self, indata, pub_key, cli_args=None):
        """Encrypts files."""

        return rsa.encrypt(indata, pub_key)
项目:SinaL2    作者:Emptyset110    | 项目源码 | 文件源码
def get_sp(self, passwd, pubkey, servertime, nonce):
        key = rsa.PublicKey(int(pubkey, 16), int('10001', 16))
        message = str(servertime) + '\t' + str(nonce) + '\n' + str(passwd)
        passwd = rsa.encrypt(message.encode('utf-8'), key)
        return binascii.b2a_hex(passwd).decode('ascii')
项目:Daily-code    作者:rui7157    | 项目源码 | 文件源码
def get_passwd(self, pubkey, servertime, nonce):
        import rsa
        rsaPublickey = int(pubkey, 16)
        key = rsa.PublicKey(rsaPublickey, 65537) #????
        message = str(servertime) + '\t' + str(nonce) + '\n' + str(self.password) #????js???????
        passwd = rsa.encrypt(message, key) #??
        passwd = binascii.b2a_hex(passwd) #????????16???
        return passwd
项目:Daily-code    作者:rui7157    | 项目源码 | 文件源码
def get_passwd(self, pubkey, servertime, nonce):
        import rsa
        rsaPublickey = int(pubkey, 16)
        key = rsa.PublicKey(rsaPublickey, 65537)  # ????
        message = str(servertime) + '\t' + str(nonce) + '\n' + \
            str(self.password)  # ????js???????
        passwd = rsa.encrypt(message, key)  # ??
        passwd = binascii.b2a_hex(passwd)  # ????????16???

        return passwd
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def upstream_recv(self, data):
        try:
            cleartext=data.peek()
            tosend=b""
            i=0
            packed_size=struct.pack("<I", len(cleartext))
            tosend=packed_size+cleartext
            tosend+=b"\x00"*(BLOCK_SIZE - (len(tosend)%BLOCK_SIZE))
            data.drain(len(cleartext))
            self.downstream.write(self.enc_cipher.encrypt(tosend))
        except Exception as e:
            logging.debug(e)
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def on_connect(self):
        pk = rsa.PublicKey.load_pkcs1(self.pubkey)
        if Random:
            self.aes_key = Random.new().read(self.key_size)
        else:
            self.aes_key = os.urandom(self.key_size)

        if AES is not None:
            self.enc_cipher = AES.new(self.aes_key, AES.MODE_CBC, self._iv_enc)
        else:
            self.enc_cipher = pyaes.AESModeOfOperationCBC(self.aes_key, iv = self._iv_enc)
        self.downstream.write(rsa.encrypt(self.aes_key, pk))
        self.downstream.write(self._iv_enc)
项目:dHydra    作者:Emptyset110    | 项目源码 | 文件源码
def get_sp(self, passwd, pubkey, servertime, nonce):
        key = rsa.PublicKey(int(pubkey, 16), int('10001', 16))
        message = str(servertime) + '\t' + str(nonce) + '\n' + str(passwd)
        passwd = rsa.encrypt(message.encode('utf-8'), key)
        return binascii.b2a_hex(passwd).decode('ascii')
项目:dHydra    作者:Emptyset110    | 项目源码 | 文件源码
def get_sp(self, passwd, pubkey, servertime, nonce):
        key = rsa.PublicKey(int(pubkey, 16), int('10001', 16))
        message = str(servertime) + '\t' + str(nonce) + '\n' + str(passwd)
        passwd = rsa.encrypt(message.encode('utf-8'), key)
        return binascii.b2a_hex(passwd).decode('ascii')
项目:PSpiderDemos    作者:xianhu    | 项目源码 | 文件源码
def get_password(self, servertime, nonce, pubkey):
        """
        get legal password, encrypt file: http://i.sso.sina.com.cn/js/ssologin.js
        """
        string = (str(servertime) + '\t' + str(nonce) + '\n' + str(self.pass_word)).encode("utf-8")
        public_key = rsa.PublicKey(int(pubkey, 16), int("10001", 16))
        password = rsa.encrypt(string, public_key)
        password = binascii.b2a_hex(password)
        return password.decode()
项目:theopencorps    作者:theopencorps    | 项目源码 | 文件源码
def encrypt(self, owner, repo_name, string):
        """
        Encrypt a string using the repositories key

        Returns a base64 encoded string suitable for use in YML file
        """
        rsa_key = self.get_key(owner, repo_name)
        pubkey = rsa.PublicKey.load_pkcs1_openssl_pem(rsa_key)
        secure = rsa.encrypt(string.encode('utf8'), pubkey)
        return base64.b64encode(secure)
项目:klouddav    作者:hojel    | 项目源码 | 文件源码
def RSA_encrypt(public_key, message):
    rsakey = rsa.PublicKey.load_pkcs1_openssl_pem(public_key)
    encrypted = rsa.encrypt(message.encode('utf-8'), rsakey)
    return base64.encodestring(encrypted).decode('utf-8').replace('\n', '')
项目:backpack.py    作者:Zwork101    | 项目源码 | 文件源码
def __init__(self, username, password, shared_secret):
        self.session = requests.session()
        self.resp = requests.post("https://store.steampowered.com" + "/login/getrsakey/", data={
            "username": str(username),
        }).json()
        self.rsa_modulus = self.rsa_params(str(username)).get('rsa_mod')
        self.rsa_exponent = self.rsa_params(str(username)).get('rsa_exp')
        self.rsa_timestamp = self.rsa_params(str(username)).get('rsa_timestamp')
        self.rsa_publickey = rsa.PublicKey(self.rsa_modulus, self.rsa_exponent)
        self.encrypted_password = base64.b64encode(rsa.encrypt(str(password).encode('UTF-8'), self.rsa_publickey))
        self.loginReq = self.loginRequest(str(username), self.encrypted_password, str(shared_secret))
项目:dHydra    作者:Michael0711    | 项目源码 | 文件源码
def get_sp(self, passwd, pubkey, servertime, nonce):
        key = rsa.PublicKey(int(pubkey, 16), int('10001', 16))
        message = str(servertime) + '\t' + str(nonce) + '\n' + str(passwd)
        passwd = rsa.encrypt(message.encode('utf-8'), key)
        return binascii.b2a_hex(passwd).decode('ascii')
项目:REMAP    作者:REMAPApp    | 项目源码 | 文件源码
def perform_operation(self, indata, pub_key, cli_args=None):
        """Encrypts files."""

        return rsa.encrypt(indata, pub_key)
项目:smart_login    作者:SpiderClub    | 项目源码 | 文件源码
def get_password(password, servertime, nonce, pubkey):
    rsaPublickey = int(pubkey, 16)
    key = rsa.PublicKey(rsaPublickey, 65537)  # ????,
    message = str(servertime) + '\t' + str(nonce) + '\n' + str(password)  # ????js???????
    message = message.encode("utf-8")
    passwd = rsa.encrypt(message, key)  # ??
    passwd = binascii.b2a_hex(passwd)  # ????????16???
    return passwd
项目:smart_login    作者:SpiderClub    | 项目源码 | 文件源码
def encript_password(password, pubkey):
    pub = rsa.PublicKey.load_pkcs1_openssl_pem(pubkey.encode('utf-8'))
    encript_passwd = rsa.encrypt(password.encode('utf-8'), pub)
    return base64.b64encode(encript_passwd).decode('utf-8')
项目:weibo_scrawler_app    作者:coolspiderghy    | 项目源码 | 文件源码
def encode_pwd(self, password, servertime, nonce, pubkey):
        rsaPublickey = int(pubkey, 16)
        key = rsa.PublicKey(rsaPublickey, 65537)  # ????
        message = str(servertime) + '\t' + str(nonce) + '\n' + str(password)  # ????js???????
        passwd = rsa.encrypt(message, key)  # ??
        passwd = binascii.b2a_hex(passwd)  # ????????16???
        return passwd

    # ????????
项目:python_demo    作者:Wasim37    | 项目源码 | 文件源码
def get_password(self, servertime, nonce, pubkey):
        """
        get legal password
        """
        string = (str(servertime) + "\t" + str(nonce) + "\n" + str(self.pass_word)).encode("utf-8")
        public_key = rsa.PublicKey(int(pubkey, 16), int("10001", 16))
        password = rsa.encrypt(string, public_key)
        password = binascii.b2a_hex(password)
        return password.decode()
项目:jtyd_python_spider    作者:xtuyaowu    | 项目源码 | 文件源码
def get_password(password, servertime, nonce, pubkey):
    rsa_publickey = int(pubkey, 16)
    key = rsa.PublicKey(rsa_publickey, 65537)
    message = str(servertime) + '\t' + str(nonce) + '\n' + str(password)
    message = message.encode("utf-8")
    passwd = rsa.encrypt(message, key)
    passwd = binascii.b2a_hex(passwd)
    return passwd


# post data and get the next url
项目:jtyd_python_spider    作者:xtuyaowu    | 项目源码 | 文件源码
def get_password(password, servertime, nonce, pubkey):
    rsa_publickey = int(pubkey, 16)
    key = rsa.PublicKey(rsa_publickey, 65537)
    message = str(servertime) + '\t' + str(nonce) + '\n' + str(password)
    message = message.encode("utf-8")
    passwd = rsa.encrypt(message, key)
    passwd = binascii.b2a_hex(passwd)
    return passwd


# post data and get the next url
项目:Analysis-of-Public-Opinion-Based-on-Microblogging-Reptile    作者:Yuzhen-Li    | 项目源码 | 文件源码
def __get_spwd(self):
          rsaPublickey = int(self.pubkey, 16)
          key = rsa.PublicKey(rsaPublickey, 65537) #????
          message = self.servertime + '\t' + self.nonce + '\n' + self.password #????js???????
          passwd = rsa.encrypt(message, key) #??
          passwd = binascii.b2a_hex(passwd) #????????16???
          return passwd
项目:OneClickDTU    作者:satwikkansal    | 项目源码 | 文件源码
def perform_operation(self, indata, pub_key, cli_args=None):
        '''Encrypts files.'''

        return rsa.encrypt(indata, pub_key)
项目:Graduation-design    作者:Baichenjia    | 项目源码 | 文件源码
def get_pwd(password, servertime, nonce, pubkey):
    rsaPublickey = int(pubkey, 16)
    key = rsa.PublicKey(rsaPublickey, 65537) #????
    message = str(servertime) + '\t' + str(nonce) + '\n' + str(password) #???????????
    passwd = rsa.encrypt(message, key)  #??
    passwd = binascii.b2a_hex(passwd)  #????????16???
    return passwd
项目:spider-practice    作者:Wooden-Robot    | 项目源码 | 文件源码
def get_sp(password, pubkey, servertime, nonce):
    # rsa??
    key = rsa.PublicKey(int(pubkey, 16), 65537)
    message = str(servertime) + '\t' + str(nonce) + '\n' + password
    passwd = rsa.encrypt(message.encode("utf8"), key)
    # ????????16??
    sp = binascii.b2a_hex(passwd)
    # print(sp)
    return sp


# ?????
项目:MyPython    作者:fupinglee    | 项目源码 | 文件源码
def enPass(self):
        exponent = self.b64tohex(self.exponent)
        modulus = self.b64tohex(self.modulus)
        rsaKey = rsa.PublicKey(int(modulus, 16), int(exponent,16))

        enPwd = binascii.b2a_hex(rsa.encrypt(self.pwd, rsaKey))
        return self.hex2b64(enPwd)
项目:SinaWeibo    作者:chengshuyi    | 项目源码 | 文件源码
def getSP(self):
        n=self.pubKey
        puk = rsa.PublicKey(int(
                n,16), 65537) 
        #ct=ciphertext
        ct=(str(self.servertime)+'\t'+str(self.nonce)+'\n'+str(self.p)).encode()
        return binascii.b2a_hex(rsa.encrypt(ct, puk)).decode()
项目:WeiboSpider    作者:cuckootan    | 项目源码 | 文件源码
def get_password(self):
        # ?????
        key = rsa.PublicKey(int(self.pre_login_data[2], 16), 65537)
        # ?? message ?????????????????????????
        message = ('\t'.join([str(self.pre_login_data[0]), self.pre_login_data[1]]) + '\n' + self.raw_password).encode('utf-8')
        # print(message)

        self.password = binascii.b2a_hex(rsa.encrypt(message, key))
        # print(self.password)