资源简介
用Python爬取新版正方教务系统课程表,涉及到rsa的加密密码。代码几乎封装了,改一下网站地址就可以使用了
代码片段和文件信息
class HB64(object):
b64byte = “ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/“
b64cpt = “=“
def hex2b64(self string):
result = ““
ptr = 0
b1 = int(“111111000000000000000000“ 2)
b2 = int(“000000111111000000000000“ 2)
b3 = int(“000000000000111111000000“ 2)
b4 = int(“000000000000000000111111“ 2)
lenth = len(string)
while ptr+6 <= lenth:
temp = int(string[ptr:ptr+6] 16)
result += self.b64byte[(temp & b1) >> 18]
result += self.b64byte[(temp & b2) >> 12]
result += self.b64byte[(temp & b3) >> 6]
result += self.b64byte[temp & b4]
ptr += 6
if lenth-ptr == 4:
temp = int(string[ptr:ptr+4] 16) << 2
result += self.b64byte[(temp & b2) >> 12]
result += self.b64byte[(temp & b3) >> 6]
result += self.b64byte[temp & b4]
result += self.b64cpt
elif lenth-ptr == 2:
temp = int(string[ptr:ptr+2] 16) << 4
result += self.b64byte[(temp & b3) >> 6]
result += self.b64byte[temp & b4]
result += self.b64cpt * 2
elif lenth-ptr == 0:
pass
else:
raise Exception
return result
def b642hex(self string):
result = ““
ptr = 0
lenth = len(string)
b1 = int(“111111110000000000000000“ 2)
b2 = int(“000000001111111100000000“ 2)
b3 = int(“000000000000000011111111“ 2)
while ptr+8 <= lenth:
temp = string[ptr:ptr+4]
temp_result = 0
for cell in range(4):
temp_result += self.b64byte.index(temp[cell]) << (6 * (3 - cell))
r1 = hex((temp_result & b1) >> 16)[2:]
r2 = hex((temp_result & b2) >> 8)[2:]
r3 = hex(temp_result & b3)[2:]
if len(r1) == 1:
r1 = ‘0‘ + r1
if len(r2) == 1:
r2 = ‘0‘ + r2
if len(r3) == 1:
r3 = ‘0‘ + r3
result += r1
result += r2
result += r3
ptr += 4
if string[-1]==“=“ and string[-2]==“=“:
temp = string[ptr:ptr+2]
temp_result = 0
temp_result += self.b64byte.index(temp[0]) << 18
temp_result += self.b64byte.index(temp[1] >> 4) << 12
r1 = hex((temp_result & b1) >> 16)[2:]
r2 = hex((temp_result & b2) >> 8)[2:]
if len(r1) == 1:
r1 = ‘0‘ + r1
if len(r2) == 1:
r2 = ‘0‘ + r2
result += r1
result += r2
elif string[-1]==“=“:
temp = string[ptr:ptr+3]
temp_result = 0
for cell in range(2):
temp_result += self.b64byte.index(temp[cell]) << (6 * (3 - cell))
temp_result += self.b64byte
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4095 2019-03-09 18:01 hex2b64.py
文件 3641 2019-03-10 21:46 login.py
文件 2942 2019-01-05 12:19 RSAJS.py
----------- --------- ---------- ----- ----
10678 3
相关资源
- RSA算法的纯Python实现源码
- 安装包feedparser-5.2.1
- SOCKET实现DES加密的全双工聊天程序
- linphone-desktop出现Cmake Error at builders/
- 英文原版-The Pyqgis Programmers Guide 1st
-
xm
l_parse.py - 基于用户相似度和社会关系和地理位
- python-iniparse-0.3.1-2.1.el6.noarch.rpm
- Read an Digit-Multimeter in Python
- 2048小游戏源码(curses)
- Learn Python in One Day and Learn It Well Pyth
- 行列式转置(reverseArray.py)
- 《Head First Python(中文版) 》:pyth
- 基于改进粒子群算法的Hammerstein模型辨
- RSA算法python实现
- DeepFool对抗算法
- python实现md5以及rsa加密方式
- 本资源基于arcpy的hurst指数算法实现,
- init_utils.py
- Vim/Gvim配置文件+配色方案_By Marslo
- head first python 源代码
- python实现简单的加密通信
评论
共有 条评论