1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| public class Code {
private String code =new String();
private char []lettre={'4','5','6','1','2','3','7','9','0','8','z','e','r','p','t','w','m',
'k','n','f','a','v','d','s','h','j','U','S','Z','M','X','Q','T','W','A','J','H','B'};
private char [] crypte;
private int []table =new int[38];
public Code(){
crypte =new char[12];
for (int i=0;i<38;i++)
{
table[i]=0;
}
}
public String codage(){
char x;int indice =0;
for (int i=0;i<12;i++)
{
do{
indice = (int) Math.random() * 37;
x =lettre[indice];
}while(table[indice]==1);
table[indice]=1;
crypte[i]=x;
}
code=String.valueOf(crypte);
return code;
}
public void affiche(){
System.out.println(code);
}
} |