Jump to content






Photo - - - - -

Starting Crypto: Caesar Cipher



Here you can enter a shift between 0-255. This metod is created in java and should be known to intimately if you want to call yourself a security expert because it is one of the earliest ones.

   //The enciphering method.
   public static byte[] caesarEncipher(byte[] message,int shift) {
      byte[] m2=new byte[message.length];
      for (int i=0;i<message.length;i++) {
         m2[i]=(byte)((message[i]+shift)%256);
      }
      return m2;
   }

   //The deciphering method.
   public static byte[] caesarDecipher(byte[] message,int shift) {
      byte[] m2=new byte[message.length];
      for (int i=0;i<message.length;i++) {
         m2[i]=(byte)((message[i]+(256-shift))%256);
      }
      return m2;
   }