ENCRYPTION

you are given a cypher text input to function getsword AND there is plain text AMMUNITION occurs some where in cyphertext
you have to find characters coresponding to the encrypted form of AMMUNITION and you can use substitution method like MM TO FIND
EXAMPLE WORD=AMMUNITION
ENCRYPTED TEXT=
A+2=C
M+2=O UP TO SO ON

INPUT CYPHER TEXT=
ABDWUSDJFHCOOWPKVKQPSMWPDHRIDDHH
HERE U HAVE TO FIND THIS WORD COOWPKVKQP IS ENCRYPTED IN THIS STRING
RETURN THAT IT CONTAINS THE ENCRYPTED WORD OR NOT

Guess is the question from Aspirations 2020. Here’s the solution by me

public class PlainTextAttack {
	 
public static char [] getwordSets(char plainText[],char cipherText[])
{
        int i,j,k,l;

        char res[]=new char[50]; 
 
                for(i=0;i<cipherText.length;i++)
                   { if((cipherText[i]<65)||(cipherText[i]>90))
                         return null;      
                      }
 
            for(i=0;i<plainText.length;i++)
                {  if((plainText[i]<65)||(plainText[i]>90))
                       return null;                                       
                   }
    
            if(cipherText.length<plainText.length)
                 return null;
 
               for(i=0;i<cipherText.length;i++)
                       {  for(j=0;j<26;j++)
                               {    for(k=0;k<plainText.length;k++)
                                              {   if((plainText[k]+j)>90)
                                                       res[k]=(char) ((plainText[k]+j)-90+64);
                                                    else 
                                                         res[k]=(char) (plainText[k]+j);
                                                  if(cipherText[i+k]==res[k])
                                                       {   if(k==(plainText.length-1))
                                                              return res;  
                                                       }
                                                 else
                                                  break;
                                               }
                  
                                  for(l=0;l<plainText.length;l++)
                                              {   if((plainText[l]-j)<65)
                                                       res[l]=(char) (91-(65-(plainText[l]-j)));
                                                    else 
                                                         res[k]=(char) (plainText[l]-j);
                                                  if(cipherText[i+l]==res[l])
                                                       {   if(l==(plainText.length-1))
                                                              return res;  
                                                       }
                                                  else
                                                  break;
                                               }
                              }
                          }   
             return null;
}
 
public static void main(String args[])
{    	
	  String strplainText="AMMUNITION";
      String strcipherText="ABDWUSDJFHCOOWPKVKQPSMWPDHRIDDHH";
      
      char plainText[]=strplainText.toCharArray();
      char cipherText[]=strcipherText.toCharArray();
      
      char[] b=new char[50];
      b=getwordSets(plainText,cipherText);
      
      System.out.println(b);
}

}