Skip to content

在EXEC JS seting 如何调用如下函数? #37

@lzfls

Description

@lzfls

/**

/*

  • encrypt the string to string made up of hex

  • return the encrypted string
    */
    function strEnc(data, firstKey, secondKey, thirdKey) {

    var leng = data.length;
    var encData = "";
    var firstKeyBt, secondKeyBt, thirdKeyBt, firstLength, secondLength, thirdLength;
    if (firstKey != null && firstKey != "") {
    firstKeyBt = getKeyBytes(firstKey);
    firstLength = firstKeyBt.length;
    }
    if (secondKey != null && secondKey != "") {
    secondKeyBt = getKeyBytes(secondKey);
    secondLength = secondKeyBt.length;
    }
    if (thirdKey != null && thirdKey != "") {
    thirdKeyBt = getKeyBytes(thirdKey);
    thirdLength = thirdKeyBt.length;
    }

    if (leng > 0) {
    if (leng < 4) {
    var bt = strToBt(data);
    var encByte;
    if (firstKey != null && firstKey != "" && secondKey != null && secondKey != "" && thirdKey != null && thirdKey != "") {
    var tempBt;
    var x, y, z;
    tempBt = bt;
    for (x = 0; x < firstLength; x++) {
    tempBt = enc(tempBt, firstKeyBt[x]);
    }
    for (y = 0; y < secondLength; y++) {
    tempBt = enc(tempBt, secondKeyBt[y]);
    }
    for (z = 0; z < thirdLength; z++) {
    tempBt = enc(tempBt, thirdKeyBt[z]);
    }
    encByte = tempBt;
    } else {
    if (firstKey != null && firstKey != "" && secondKey != null && secondKey != "") {
    var tempBt;
    var x, y;
    tempBt = bt;
    for (x = 0; x < firstLength; x++) {
    tempBt = enc(tempBt, firstKeyBt[x]);
    }
    for (y = 0; y < secondLength; y++) {
    tempBt = enc(tempBt, secondKeyBt[y]);
    }
    encByte = tempBt;
    } else {
    if (firstKey != null && firstKey != "") {
    var tempBt;
    var x = 0;
    tempBt = bt;
    for (x = 0; x < firstLength; x++) {
    tempBt = enc(tempBt, firstKeyBt[x]);
    }
    encByte = tempBt;
    }
    }
    }
    encData = bt64ToHex(encByte);
    } else {
    var iterator = parseInt(leng / 4);
    var remainder = leng % 4;
    var i = 0;
    for (i = 0; i < iterator; i++) {
    var tempData = data.substring(i * 4 + 0, i * 4 + 4);
    var tempByte = strToBt(tempData);
    var encByte;
    if (firstKey != null && firstKey != "" && secondKey != null && secondKey != "" && thirdKey != null && thirdKey != "") {
    var tempBt;
    var x, y, z;
    tempBt = tempByte;
    for (x = 0; x < firstLength; x++) {
    tempBt = enc(tempBt, firstKeyBt[x]);
    }
    for (y = 0; y < secondLength; y++) {
    tempBt = enc(tempBt, secondKeyBt[y]);
    }
    for (z = 0; z < thirdLength; z++) {
    tempBt = enc(tempBt, thirdKeyBt[z]);
    }
    encByte = tempBt;
    } else {
    if (firstKey != null && firstKey != "" && secondKey != null && secondKey != "") {
    var tempBt;
    var x, y;
    tempBt = tempByte;
    for (x = 0; x < firstLength; x++) {
    tempBt = enc(tempBt, firstKeyBt[x]);
    }
    for (y = 0; y < secondLength; y++) {
    tempBt = enc(tempBt, secondKeyBt[y]);
    }
    encByte = tempBt;
    } else {
    if (firstKey != null && firstKey != "") {
    var tempBt;
    var x;
    tempBt = tempByte;
    for (x = 0; x < firstLength; x++) {
    tempBt = enc(tempBt, firstKeyBt[x]);
    }
    encByte = tempBt;
    }
    }
    }
    encData += bt64ToHex(encByte);
    }
    if (remainder > 0) {
    var remainderData = data.substring(iterator * 4 + 0, leng);
    var tempByte = strToBt(remainderData);
    var encByte;
    if (firstKey != null && firstKey != "" && secondKey != null && secondKey != "" && thirdKey != null && thirdKey != "") {
    var tempBt;
    var x, y, z;
    tempBt = tempByte;
    for (x = 0; x < firstLength; x++) {
    tempBt = enc(tempBt, firstKeyBt[x]);
    }
    for (y = 0; y < secondLength; y++) {
    tempBt = enc(tempBt, secondKeyBt[y]);
    }
    for (z = 0; z < thirdLength; z++) {
    tempBt = enc(tempBt, thirdKeyBt[z]);
    }
    encByte = tempBt;
    } else {
    if (firstKey != null && firstKey != "" && secondKey != null && secondKey != "") {
    var tempBt;
    var x, y;
    tempBt = tempByte;
    for (x = 0; x < firstLength; x++) {
    tempBt = enc(tempBt, firstKeyBt[x]);
    }
    for (y = 0; y < secondLength; y++) {
    tempBt = enc(tempBt, secondKeyBt[y]);
    }
    encByte = tempBt;
    } else {
    if (firstKey != null && firstKey != "") {
    var tempBt;
    var x;
    tempBt = tempByte;
    for (x = 0; x < firstLength; x++) {
    tempBt = enc(tempBt, firstKeyBt[x]);
    }
    encByte = tempBt;
    }
    }
    }
    encData += bt64ToHex(encByte);
    }
    }
    }
    return encData;
    }

在其他位置,又有如下:
$("#rsa").val(strEnc(u + p + b, '1', '2', '3'));
u + p + b 对应如上面函数参数的data ,1、2、3对应firstkey、secondkey、thirdkey

此函数如何在EXEC JS seting 调用呢?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions