Docstoc

Dehiffrement Cesar

Document Sample
Dehiffrement Cesar Powered By Docstoc
					public class DehiffrementCesar {

       public static void main(String[] args) {

               String lettres="abcdefghijklmnopqrstuvwxyz";

          String message="";

          String messagChiffre="rovvy gybvn, s kw fobi rkzzi dy lo gsdr iye sx mvkcc";

          int k=10;



          for(int i=0; i<messagChiffre.length();i++){

                String carctereEncours=messagChiffre.substring(i, i+1);

                String caractereDechiffre="";

                if((",".equals(carctereEncours))||(" ".equals(carctereEncours))){

                         caractereDechiffre=carctereEncours;



                }else{



                         int rang=lettres.indexOf(carctereEncours);

                         if((rang-k)<0){



                                 rang=rang+26;

                         }

                         int t0=(rang-k)%26;

                         caractereDechiffre=lettres.substring(t0, t0+1);



                }

                message=message+caractereDechiffre;

          }// fin boucle for
    System.out.println(messagChiffre);

    System.out.println(message);



        }



}

				
DOCUMENT INFO
Shared By:
Stats:
views:5
posted:6/23/2012
language:Norwegian
pages:2
Description: Cours de S�curit� informatique avec plusieurs code de cryptage: RSA, chiffrement Affine , Cesar