admin管理员组文章数量:1583571
效果图
代码中用到了Crypto
模块,Windows安装时会报错,① 建议选择对应解释器的版本搜索安装依赖.whl
后缀的依赖包文件,找到之后直接pip install XXX.whl
就可以了,在文章后面我提供了百度网盘连接,可以下载安装依赖、源码以及打包后的exe文件,我下载的是python3.6的依赖包,② window下安装pycryptodome
模块也可以,pip install pycryptodome
,但是由于这个模块暂时没有更新维护,安装了有时候无法使用,python3.6和python3.7已经亲测无法使用,③ Linux不需要考虑这个编译环境问题,可以直接安装Crypto
即可
from copy import deepcopy
import requests, json, base64
from binascii import hexlify
from Crypto.Cipher import AES
from tkinter import *
from tkinter.filedialog import askdirectory
from urllib.request import urlretrieve
import os
class Encrypyed():
'''传入歌曲的ID,加密生成'params'、'encSecKey 返回'''
def __init__(self):
self.pub_key = '010001'
self.modulus = '00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280104e0312ecbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d813cfe4875d3e82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7'
self.nonce = '0CoJUm6Qyw8W8jud'
def create_secret_key(self, size):
return hexlify(os.urandom(size))[:16].decode('utf-8')
def aes_encrypt(self, text, key):
iv = '0102030405060708'
pad = 16 - len(text) % 16
text = text + pad * chr(pad)
encryptor = AES.new(key, AES.MODE_CBC, iv)
result = encryptor.encrypt(text)
result_str = base64.b64encode(result).decode('utf-8')
return result_str
def rsa_encrpt(self, text, pubKey, modulus):
text = text[::-1]
rs = pow(int(hexlify(text.encode('utf-8')), 16), int(pubKey, 16), int(modulus, 16))
return format(rs, 'x').zfill(256)
def work(self, ids, br=128000):
text = {
'ids': [ids], 'br': br, 'csrf_token': ''}
text = json.dumps(text)
i = self.create_secret_key(16)
encText = self.aes_encrypt(text, s
版权声明:本文标题:python网易云音乐下载,可选择歌曲,下载路径 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dongtai/1727921899a1138291.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论