Encoding and decoding passwords with character rotation

Asked

Viewed 137 times

3

I have a database with a password field, which has a sort of "encryption".

Analyzing the logic: I created users in the system and put the password: 123. When I went to check the password in the bank it was: 032.

If we go to a logical reasoning, when I put 1, it generated 0 (a value below); when I put 2, it generated 3 (a value above) and then 3, it generated 2 (a value below).

Other examples:

SENHA                        RESULTADO NO BANCO
abcdefghijklmnopqrstuvwxyz   'cbedgfihkjmlonqpsrutwvyx{
ABCDEFGHIJKLMNOPQRSTUVWXYZ   @CBEDGFIHKJMLONQPSRUTWVYX[
0123456789                   1032547698 

(reading the password it will replace at each position one value above and another below).

How can I generate this logic in Java?

  • Friend this may help you edit: http://answall.com/help/mcve

  • William Nascimento, thank you very much. But from what I put up there I could understand that I don’t have the code, I want to develop it from the reported logic.

  • 1

    Follow the solution if they reopen as a response. http://ideone.com/lIUpWe Note that you edited with the example of "master" but if it is really alternated, the result is different. Create users with longer passwords, such as 333333, dddddd, etc to see if logic proceeds.

  • Hi Bacco, I created these passwords: created password : abcdefghijklmnopqrstuvwxyz - database result: 'cbedgfihkjmlonqpsrutwvyx{ Created password : ABCDEFGHIJKLMNOPQRSTUVWXYZ - Database result: @CBEDGFIHKJMLONQPSRUTWVYX[ Password Created : 0123456789 - Bank Result: 1032547698

  • Yeah, it looks okay. Did you see the link I posted? to decide the first character whether it is "up" or "down" just invert j ( int j=1 to int j=-1 ) http://ideone.com/lIUpWe

  • now, if these examples are right, it may be that the "sense" varies according to the ID being even or odd, or qq another crazy idea, because in each case the "rotation" is to one side.

  • I saw Bacco, but analyzing his code he makes a position kind of fixed, because when I did the test in the typing code: master he did not return me, example the "a" as " ". It returns me this value if the "a" is in the first position, understood?

  • I understood perfectly, the problem is if it’s 1 down and 1 up, or it’s lb, or it’s n' the start. it depends on the position. It may be that logic uses something else that you didn’t consider, such as the parity of the previous character, or some other component that isn’t only in 1 -1 1 1 -1 1 -1 - this will tell you if you test with aaabbbbccc for example.

  • Thanks man, you’re helping me a lot. But from what I’m seeing, he doesn’t follow this logic.

  • That’s the danger of asking the question based on an initial impression. The best thing to do would be to test several different examples, and make a table with the results, not just similar sequences. The more samples, the more chance to understand. It may even be that the Name field influences the password, who knows. Just testing. Registering 3 times the same password and seeing if they match is another relevant test.

  • but I have this information in his Bank, and I see that the values do not merge (1 up and another down) so help to generate a code that does the same thing. From what I see, it is as if it were substitution, ex: "a" = "'", etc...and as if it followed the ascii table, where before the "a" comes "'" and before the "a" comes "@"

  • I saw another password here: Encrypted Password : O@U@M3105 - ?

  • Just to answer your last comment, before the @Bacco issue your question was very confusing, so whether or not you have code, you should understand that what is obvious to you depending on the way you write may not be clear to others. Note: When you reply to someone specific use @NomeDoUsuario, because if nothing appears in "INBOX". Good night.

Show 8 more comments

1 answer

5

As I mentioned in the comments, to rotate the characters "up" and "down" alternately, this code is enough:

    String s = "ABCDEmasterbbbbbbb123";
    int j = -1;
    for (int i = 0; i < s.length(); i++) {
        char c = s.charAt(i);
        c += j;
        j = -j;
        System.out.print(c);
    }
    System.out.println();

See working on IDEONE.

As you noticed, your example’s toggle sometimes starts with -1, and sometimes with +1. To do this in the code, just change the line int j = -1; applying to the logic that determines the "side" of the alternation.

With the data of the question, in principle the solution is this. What is missing is to find what is the criterion to determine the j initial, but it is mere setting in the code. For example, it may be that the ID is even or not, or depends on another field of the table. There already depends on the analysis of the data.

Browser other questions tagged

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