我在反应本机代码中寻找以下代码逻辑。如果您知道以下代码转换为本机代码,请告诉我。我是反应原生发展的新手。
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent hh)//Method to perform action on clicking
{
f=cb.getSelectedIndex();
for(i=0;i<c;i++)
{
if(i==f)
{
P=copy2[i];
}
}
try
{
frame.pack();
frame.dispose();
obj.arrive();
}
catch(IOException e)
{
e.printStackTrace();
}
}
});
答案 0 :(得分:1)
上面的代码很简单“字符串加密方法”,它可以很容易地用JS编写,具有相同的逻辑,
Encrypt_Decrypt = (str)=>{
let length = str.length;
let encryptyed_str = "";
for(let i = 0; i< length ; i++){
let Key_To_Use = length + i + 1;
Key_To_Use = ((255 + Key_To_Use) % 255);
let Byte_To_Be_Encrypted = str[i];
let Ascii_Num_Byte_To_Encrypt = str[i].charCodeAt(0);
let Xored_Byte = Ascii_Num_Byte_To_Encrypt ^ Key_To_Use;
let Encrypted_Byte = String.fromCharCode(Xored_Byte);
encryptyed_str = encryptyed_str+Encrypted_Byte;
}
return encryptyed_str;
}
for Encrypt_Decrypt('aaa'); 它给出了“edg”