Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Problem with encryption with pasword

  1. #1
    Junior Member
    Join Date
    Dec 2017
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem with encryption with pasword

    Hello
    i write program for encryption with use pasword. In some cases (pasword its word like belgija program dont decryption normal, if i use another vord or i spell it and use letther word belgija i get normal result ) where its mistake?


    //code for  encryption
     String znakm kljuc2, beseda3;
        char znak2;
    int aaa;
    kljuc2 = beseda3;
             aaa = kljuc2.length();
        for (int stevec = 0; stevec < aaa; stevec++){
    znak2 = kljuc2.charAt(stevec);
              znak = Character.toString(znak2);
           switch (znak){
            case "1" : case "q" : case "w" : case "v" : case "b" : 
            case "2" : case "!" : case "e" : case "c" : case "n" : 
            case "S" : case "D" : case "Z" : case "T" : case "Ł":
            case "ł":
            spirala();
            break;
            case "3": case "#" : case "r" : case "m" : case "," : 
            case "4" : case "$" : case "t" : case "x" : case "." : 
            case "A" : case "F" : case "U" : case "R" : case "":
            case "@":
            gordoll();
            break;
            case "5": case "%" : case "z" : case "y" : case "-" : 
            case "6" : case "&" : case "u" : case "<" : case "_" :
            case ">" : case "G" : case "I" : case "E" : case "":
            gordol();
            break;
            case "7": case "/" : case "i" : case "a" : case ":" : 
            case "8" : case "(" : case "o" : case "s" :  case ";" :
            case "Y" : case "H" : case "O" : case "W" : case "":
            doll();
            break;
            case "9": case ")" : case "p" : case "d" :  case "M" :
            case "0" : case "=" : case "l" : case "f" :  case "N" :
            case "X" : case "J" : case "P" : case "Q" : case "":
            gor();
            break;
            case "'": case "?" : case "k" : case "g" :  case "B" :
            case "+" : case "*" : case "j" : case "h" :  case "V" :
            case "C" : case "K" : case "L" :  case "|":  case "€" :
            dol();
            break;
       }     
            }
     
    //code for  decryption
     String znakm kljuc2, beseda3;
        char znak2;
    int aaa;
     
    aaa = kljuc2.length();
        for (int stevec = 0; stevec < aaa; stevec++){
    znak2 = kljuc2.charAt(stevec);
              znak = Character.toString(znak2);
           switch (znak){
            case "1" : case "q" : case "w" : case "v" : case "b" : 
            case "2" : case "!" : case "e" : case "c" : case "n" : 
            case "S" : case "D" : case "Z" : case "T" : case "Ł":
            case "ł":
            spirala2();
            break;
            case "3": case "#" : case "r" : case "m" : case "," : 
            case "4" : case "$" : case "t" : case "x" : case "." : 
            case "A" : case "F" : case "U" : case "R" : case "":
            case "@":
            gordoll2();
            break;
            case "5": case "%" : case "z" : case "y" : case "-" : 
            case "6" : case "&" : case "u" : case "<" : case "_" :
            case ">" : case "G" : case "I" : case "E" : case "":
            gordol2();
            break;
            case "7": case "/" : case "i" : case "a" : case ":" : 
            case "8" : case "(" : case "o" : case "s" :  case ";" :
            case "Y" : case "H" : case "O" : case "W" : case "":
            doll2();
            break;
            case "9": case ")" : case "p" : case "d" :  case "M" :
            case "0" : case "=" : case "l" : case "f" :  case "N" :
            case "X" : case "J" : case "P" : case "Q" : case "":
            gor2();
            break;
            case "'": case "?" : case "k" : case "g" :  case "B" :
            case "+" : case "*" : case "j" : case "h" :  case "V" :
            case "C" : case "K" : case "L" :  case "|":  case "€" :
            dol2();
            break;
       }     
            }
    Last edited by pingusteam; December 22nd, 2017 at 03:24 AM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,899
    Thanks
    52
    Thanked 2,335 Times in 2,291 Posts

    Default Re: Problem with encryption with pasword

    Please post the contents of the console from when the program is executed and shows what you are asking about.

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Dec 2017
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problem with encryption with pasword

    Some letters cant be first letter ( get wrong decoding message)
    My code for decyption:
    //kljuc2 its password       
      kljuc2 = beseda3;
             aaa = kljuc2.length();
        for (int stevec = 0; stevec < aaa; stevec++){
    znak2 = kljuc2.charAt(stevec);
              znak = Character.toString(znak2);
           switch (znak){
            case "1" : case "q" : case "w" : case "v" : case "b" : 
            case "2" : case "!" : case "e" : case "c" : case "n" : 
            case "S" : case "D" : case "Z" : case "T" : case "Ł":
            case "ł":
            spirala();
            break;
            case "3": case "#" : case "r" : case "m" : case "," : 
            case "4" : case "$" : case "t" : case "x" : case "." : 
            case "A" : case "F" : case "U" : case "R" : case "":
            case "@":
            gordoll();
            break;
            case "5": case "%" : case "z" : case "y" : case "-" : 
            case "6" : case "&" : case "u" : case "<" : case "_" :
            case ">" : case "G" : case "I" : case "E" : case "":
            gordol();
            break;
            case "7": case "/" : case "i" : case "a" : case ":" : 
            case "8" : case "(" : case "o" : case "s" :  case ";" :
            case "Y" : case "H" : case "O" : case "W" : case "":
            doll();
            break;
            case "9": case ")" : case "p" : case "d" :  case "M" :
            case "0" : case "=" : case "l" : case "f" :  case "N" :
            case "X" : case "J" : case "P" : case "Q" : case "":
            gor();
            break;
            case "'": case "?" : case "k" : case "g" :  case "B" :
            case "+" : case "*" : case "j" : case "h" :  case "V" :
            case "C" : case "K" : case "L" :  case "|":  case "" :
            dol();
            break;
       }     
            }
    my code for encyption
    // kljuc uts password
     kljuc2 = beseda3;       
     
    aaa = kljuc2.length();
        for (int stevec = 0; stevec < aaa; stevec++){
    znak2 = kljuc2.charAt(stevec);
              znak = Character.toString(znak2);
           switch (znak){
            case "1" : case "q" : case "w" : case "v" : case "b" : 
            case "2" : case "!" : case "e" : case "c" : case "n" : 
            case "S" : case "D" : case "Z" : case "T" : case "Ł":
            case "ł":
            spirala2();
            break;
            case "3": case "#" : case "r" : case "m" : case "," : 
            case "4" : case "$" : case "t" : case "x" : case "." : 
            case "A" : case "F" : case "U" : case "R" : case "":
            case "@":
            gordoll2();
            break;
            case "5": case "%" : case "z" : case "y" : case "-" : 
            case "6" : case "&" : case "u" : case "<" : case "_" :
            case ">" : case "G" : case "I" : case "E" : case "":
            gordol2();
            break;
            case "7": case "/" : case "i" : case "a" : case ":" : 
            case "8" : case "(" : case "o" : case "s" :  case ";" :
            case "Y" : case "H" : case "O" : case "W" : case "":
            doll2();
            break;
            case "9": case ")" : case "p" : case "d" :  case "M" :
            case "0" : case "=" : case "l" : case "f" :  case "N" :
            case "X" : case "J" : case "P" : case "Q" : case "":
            gor2();
            break;
            case "'": case "?" : case "k" : case "g" :  case "B" :
            case "+" : case "*" : case "j" : case "h" :  case "V" :
            case "C" : case "K" : case "L" :  case "|":  case "" :
            dol2();
            break;
       }     
            }
    first im create program with QT designer in c++ code and program work normal with all letters
    // kljuc2 its password
            kljuc2 = ui->geslo->text();
            aaa = kljuc2.size();
        test2= -1;
        for (int stevec = 0; stevec < aaa; stevec++)
        {
            test2 = test2 +1;
            znak2 = kljuc2.mid(test2, 1);
            if ((znak2 == ("1")) || (znak2 == ("5")) || (znak2 == ("9")) || (znak2 == ("e")) || (znak2 == ("u")) || (znak2 == ("a")) || (znak2 == ("g")) || (znak2 == ("4"))  || (znak2 == ("8")) || (znak2 == ("w")) || (znak2 == ("z"))  || (znak2 == ("p")) || (znak2 == ("f")) || (znak2 == ("k")) || (znak2 == ("v")) || (znak2 == ("V")) || (znak2 == ("L")) || (znak2 == ("G")) || (znak2 == ("A")) || (znak2 == ("U")) ||  (znak2 ==("E")))
                {
            dol();
                    }
           if ((znak2 == ("2"))|| (znak2 == ("6"))  || (znak2 == ("0")) || (znak2 == ("r"))  || (znak2 == ("i")) || (znak2 == ("s"))  || (znak2 == ("h")) || (znak2 == ("c")) || (znak2 == ("m")) || (znak2 == ("M"))  || (znak2 == ("C")) || (znak2 == ("K"))  || (znak2 == ("F")) || (znak2 == ("P"))  || (znak2 == ("y")) || (znak2 == ("b"))  || (znak2 == ("B")) || (znak2 == ("Y")) || (znak2 == ("H")) || (znak2 == ("S")) || (znak2 == ("I")) || (znak2 ==("R")))
                {
                     gordol();
        //             vnos->append(znak2);
                 }
        if ((znak2 == ("3"))  || (znak2 == ("7"))  || (znak2 == ("q")) || (znak2 == ("t")) || (znak2 == ("o")) || (znak2 == ("d")) || (znak2 == ("j")) || (znak2 == ("T"))  || (znak2 == ("Q")) ||  (znak2 == ("x")) || (znak2 == ("n"))  || (znak2 == ("N")) || (znak2 == ("X")) || (znak2 == ("J"))  || (znak2 == ("D")) || (znak2 == ("O")) || (znak2 == ("Z")) || (znak2 == ("w")))
        {
                   spirala();
                   }
        }
    How I can fixed my problem? Im try with if but program dont work with if. How I rewrite my C++ code in java?

  4. #4
    Junior Member
    Join Date
    Dec 2017
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problem with encryption with pasword

    If I wont that password work corecly I must

     String beseda3; // this its  password
    beseda3 = mygeslo.getText();
     beseda3 = "o"+beseda3;

Similar Threads

  1. Re: Simple encryption/ decryption problem
    By vynramiscal21 in forum Loops & Control Statements
    Replies: 0
    Last Post: December 10th, 2013, 07:26 PM
  2. Replies: 0
    Last Post: September 6th, 2012, 10:57 AM
  3. Encryption problem with CipherInputStream/CipherOutputStream
    By cjbon in forum What's Wrong With My Code?
    Replies: 19
    Last Post: July 17th, 2012, 03:15 AM
  4. Simple encryption/ decryption problem
    By searchformeaning in forum Loops & Control Statements
    Replies: 2
    Last Post: May 7th, 2012, 01:34 AM
  5. Replies: 2
    Last Post: September 23rd, 2011, 11:54 AM