result in java code

Asked

Viewed 46 times

1

I’m having a hard time in an exercise

The goal of the exercise was to know what password would give as output .

use this as original "jU5t_a_sna_3lpm17ga45_u_4_mbrf4c" and through the for-loops and byte arrays below discover the final result! But I’m not getting there, I wonder if someone could help me?

public boolean checkPassword(String password) {
    if (password.length() != 32) {
        return false;
    }
    char[] buffer = new char[32];
    int i;
    for (i=0; i<8; i++) {
        buffer[i] = password.charAt(i);
    }
    for (; i<16; i++) {
        buffer[i] = password.charAt(23-i);
    }
    for (; i<32; i+=2) {
        buffer[i] = password.charAt(46-i);
    }
    for (i=31; i>=17; i-=2) {
        buffer[i] = password.charAt(i);
    }
    String s = new String(buffer);
    return s.equals("jU5t_a_sna_3lpm17ga45_u_4_mbrf4c");
  • You can see that all this method does is to change the order of some letters. If you extract a method that produces the s and feed it with the String given at the end, which is "jU5t_a_sna_3lpm17ga45_u_4_mbrf4c", you’ll see that the exit is "jU5t_a_s1mpl3_an4gr4m_4_u_5baf7c", which is the answer you seek.

  • is correct Thank you very much !!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.