Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

加密报错 #2

Open
Z2549 opened this issue Sep 1, 2023 · 2 comments
Open

加密报错 #2

Z2549 opened this issue Sep 1, 2023 · 2 comments

Comments

@Z2549
Copy link

Z2549 commented Sep 1, 2023

账号的部分密码会导致在加密时出现超长错误

@Z2549
Copy link
Author

Z2549 commented Sep 1, 2023

File "C:\Users\admin\Desktop\jxnu_srun-master\jxnu_wifi.py", line 110, in
do_complex_work()
File "C:\Users\admin\Desktop\jxnu_srun-master\jxnu_wifi.py", line 80, in do_complex_work
i="{SRBX1}"+get_base64(get_xencode(i,token))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\admin\Desktop\jxnu_srun-master\encryption\srun_base64.py", line 17, in get_base64
b10 = (_getbyte(s, i) << 16) | (_getbyte(s, i + 1) << 8) | _getbyte(s, i + 2);
^^^^^^^^^^^^^^
File "C:\Users\admin\Desktop\jxnu_srun-master\encryption\srun_base64.py", line 4, in _getbyte
x = ord(s[i]);
~^^^
IndexError: string index out of range

@foggy-frost-forest
Copy link

源代码的base64有点问题, 当len(s)%3==0时会报错, 可以换成下面这个

def get_base64(s):
    i=0
    b10=0
    x = []
    imax = len(s) - len(s) % 3;
    if len(s) == 0:
        return s
    for i in range(0,imax,3):
        b10 = (_getbyte(s, i) << 16) | (_getbyte(s, i + 1) << 8) | _getbyte(s, i + 2);
        x.append(_ALPHA[(b10 >> 18)]);
        x.append(_ALPHA[((b10 >> 12) & 63)]);
        x.append(_ALPHA[((b10 >> 6) & 63)]);
        x.append(_ALPHA[(b10 & 63)])
    i=imax
    if len(s) - imax ==1:
        b10 = _getbyte(s, i) << 16;
        x.append(_ALPHA[(b10 >> 18)] + _ALPHA[((b10 >> 12) & 63)] + _PADCHAR + _PADCHAR);
    elif len(s) - imax ==2:
        b10 = (_getbyte(s, i) << 16) | (_getbyte(s, i + 1) << 8);
        x.append(_ALPHA[(b10 >> 18)] + _ALPHA[((b10 >> 12) & 63)] + _ALPHA[((b10 >> 6) & 63)] + _PADCHAR);
    return "".join(x)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants