강한 지혜

2121 단어 JS
js 암호화 함수
function(ret) {
    if (ret.data == 'no') {
        return false;
    } else {
        var data = ret.data ;// 
        var scode = data.split("#")[0];
        var sxh = data.split("#")[1];
        var code = document.getElementById("Form1").USERNAME.value + '%%%' + document.getElementById("Form1").PASSWORD.value;
        var encoded = '';
        for (var i = 0; i < code.length; i++) {
            if (i < 20) {
                encoded = encoded + code.substring(i, i + 1) + scode.substring(0, parseInt(sxh.substring(i, i + 1)));
                scode = scode.substring(parseInt(sxh.substring(i, i + 1)), scode.length);
            } else {
                encoded = encoded + code.substring(i, code.length);
                i = code.length;
            }
          // 
          encode = encode 
        }



python 간소화된 암호화 함수
dataStr = 'Xf6IdjyLrb793B9xcPBe40Uv5b5ml99d2XfYw1dxQ#13331111233312223312'# 
scode=dataStr.split("#")[0]# 
sxh=dataStr.split("#")[1] #salt
account = ''# 
password= ''# 
code=account +"%%%"+ password
encoded=""
for i in range(0,len(code)):
    if i < 20:
        index = int(sxh[i])
        encoded = encoded + code[i] + scode[0:index]
        scode = scode[index:len(scode)]
    else:
        encoded = encoded + code[i:len(code)]
print(encoded)# 

python 복호화 함수
salt = '13331111233312223312'    #salt
def simple_decode(encoded,salt):
    sxh=salt
    decoded = ''
    for i in range(0,len(sxh)):
        n = int(sxh[i])
        code = encoded[0:n]
        n = 1+ n
        encoded = encoded[n:]
        if len(code)>0:
            decoded = decoded + code[0]
        else:
            break
    replace_length = 1
    while True:
        if len(encoded) > replace_length:
            encoded = encoded[0:len(encoded)-replace_length]
            replace_length += 1
        else:
            break
    decoded = decoded + encoded
    return decoded

좋은 웹페이지 즐겨찾기