Monday, March 23, 2015
Simplest codes in JAVA- Brute Force attack for Substitution Cipher
package pkgnew;
import java.io.*;
import javax.swing.JOptionPane;
public class New
{
static void gui()throws IOException
{ String s1=JOptionPane.showInputDialog("Plaease");
//char[] arr= new char[s1.length()];
//double[] arr1=new double[s1.length()];
for(char aa='a';aa<='z';aa++)
{ for(char bb='a';bb<='z';bb++)
{ if(aa==bb){}
for(char cc='a';cc<='z';cc++)
{ if(cc==(aa|bb)){}
for(char dd='a';dd<='z';dd++)
{ if(dd==(aa|bb|cc)){}
for(char ee='a';ee<='z';ee++)
{ if(ee==(aa|bb|cc|dd)){}
for(char ff='a';ff<='z';ff++)
{ if(ff==(aa|bb|cc|dd|ee)){}
for(char gg='a';gg<='z';gg++)
{ if(gg==(aa|bb|cc|dd|ee|ff)){}
for(char hh='a';hh<='z';hh++)
{ if(hh==(aa|bb|cc|dd|ee|ff|gg)){}
for(char ii='a';ii<='z';ii++)
{ if(ii==(aa|bb|cc|dd|ee|ff|gg|hh)){}
for(char jj='a';jj<='z';jj++)
{ if(jj==(aa|bb|cc|dd|ee|ff|gg|hh|ii)){}
for(char kk='a';kk<='z';kk++)
{ if(kk==(aa|bb|cc|dd|ee|ff|gg|hh|ii|jj)){}
for(char ll='a';ll<='z';ll++)
{ if(ll==(aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk)){}
for(char mm='a';mm<='z';mm++)
{ if(mm==(aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll)){}
for(char nn='a';nn<='z';nn++)
{ if(nn==(aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm)){}
for(char oo='a';oo<='z';oo++)
{ if(oo==(aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn)){}
for(char pp='a';pp<='z';pp++)
{ if(pp==(aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn|oo)){}
for(char qq='a';qq<='z';qq++)
{ if(qq==(aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn|oo|pp)){}
for(char rr='a';rr<='z';rr++)
{ if(rr==(aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn|oo|pp|qq)){}
for(char ss='a';ss<='z';ss++)
{ if(ss==(aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn|oo|pp|qq|rr)){}
for(char tt='a';tt<='z';tt++)
{ if(tt==(aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn|oo|pp|qq|rr|ss)){}
for(char uu='a';uu<='z';uu++)
{ if(uu==(aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn|oo|pp|qq|rr|ss|tt)){}
for(char vv='a';vv<='z';vv++)
{ if(vv==(aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn|oo|pp|qq|rr|ss|tt|uu)){}
for(char ww='a';ww<='z';ww++)
{ if(ww==(aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn|oo|pp|qq|rr|ss|tt|uu|vv)){}
for(char xx='a';xx<='z';xx++)
{ if(xx==(aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn|oo|pp|qq|rr|ss|tt|uu|vv|ww)){}
for(char yy='a';yy<='z';yy++)
{ if(yy==(aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn|oo|pp|qq|rr|ss|tt|uu|vv|ww|xx)){}
for(char zz='a';zz<='z';zz++)
{ if(zz==(aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn|oo|pp|qq|rr|ss|tt|uu|vv|ww|xx|yy)){}
s1=s1.replace('a', aa);s1=s1.replace('b', bb);s1=s1.replace('c', dd);
s1=s1.replace('d', dd);s1=s1.replace('e', ee);s1=s1.replace('f', ff);
s1=s1.replace('g', gg);s1=s1.replace('h', hh);s1=s1.replace('i', ii);
s1=s1.replace('j', jj);s1=s1.replace('k', kk);s1=s1.replace('l', ll);
s1=s1.replace('m', mm);s1=s1.replace('n', nn);s1=s1.replace('o', oo);
s1=s1.replace('p', pp);s1=s1.replace('q', qq);s1=s1.replace('r', rr);
s1=s1.replace('s', ss);s1=s1.replace('t', uu);s1=s1.replace('v', vv);
s1=s1.replace('w', ww);s1=s1.replace('x', xx);s1=s1.replace('y', yy);
s1=s1.replace('z', zz);s1=s1.replace('u', uu);
if(s1.contains("that")||s1.contains("is")||s1.contains("up")||s1.contains("you")||s1.contains("meet")||
s1.contains("sky")||s1.contains("cool")||s1.contains("my")||s1.contains("me")||s1.contains("in")||s1.contains("of")||s1.contains("was"))
{System.out.println(s1);System.in.read();}
else{long k=0;k++;System.out.println(k);}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}}
public static void main(String args[])throws IOException
{
gui();
System.out.println("I have returned in main");
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment