Nieuw lid |
|
Hallo,
ik heb volgende java-code:
public void actionPerformed(ActionEvent e)
{
String user = getUserField().getText();
if(user.equals("Gosling"))
{
char password[] = (getParameter("param") + getPasswordField().getText()).toCharArray();
StringBuffer buffer = new StringBuffer();
for(int i = 0; i < password.length; i++)
{
password[i] >>= '\001';
buffer.append(Integer.toHexString(password[i]));
}
if(buffer.toString().equals("30313131373736") && getPasswordField().getText().charAt(1) == getPasswordField().getText().charAt(2))
{
msgLabel.setText("Correct!");
} else
{
msgLabel.setText("Wrong!");
}
} else
{
msgLabel.setText("Wrong!");
}
}
public void actionPerformed(ActionEvent e) { String user = getUserField ().getText(); if(user.equals("Gosling")) { char password [] = (getParameter ("param") + getPasswordField ().getText()).toCharArray (); StringBuffer buffer = new StringBuffer(); for(int i = 0; i < password.length; i++) { password[i] >>= '\001'; buffer.append(Integer.toHexString(password[i])); } if(buffer .toString ().equals ("30313131373736") && getPasswordField ().getText().charAt (1) == getPasswordField ().getText().charAt (2)) { msgLabel.setText("Correct!"); } else { msgLabel.setText("Wrong!"); } } else { msgLabel.setText("Wrong!"); } }
(parameter 'param'='abc')
Nu wil ik deze naar JS omzetten:
var hash;
document.form.user.value = "Gosling";
var user;
user = document.form.user.value;
var pass;
pass = document.form.pass.value;
pw = new Array;
pw = pass.match(/.{1}/g);
for(i = 0; i < pw.length; i++)
{
pw[i] >>= '\001';
hash=hash + pw[i].toString();
}
var hash; document.form.user.value = "Gosling"; var user; user = document.form.user.value; var pass; pass = document.form.pass.value; pw = pass.match(/.{1}/g); for(i = 0; i < pw.length; i++) { pw[i] >>= '\001'; hash=hash + pw[i].toString(); }
Dat is wat ik er van heb kunnen maken. Wie kan/wil me verderhelpen?
(Of wie vertelt me ineens wat 'password' moet zijn in de Java-code opdat ik de melding 'Correct!' krijg?)
|