Facebook
From Tinct Zebra, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 205
  1. public class Main {
  2.  
  3.     private static String mainKey;
  4.     private static String mainCipher;
  5.  
  6.     public static void main(String[] args) {
  7.         mainKey = convertToBinary("YAMEO");
  8.         mainCipher = convertToBinary("5f67fc6c0b8e73c39188cea354bb31eb85008ae1b6c51c16a4dfd8c0509fb960a8241f6d9a8e700450d5553acabe01d3e03b4cbf3050a54en" +
  9.                 "5f67fc6c0b8e73c39188cea354bb31eb85008ae1b6c51c16a4dfd8c0509fb960a8241f6d9a8e700450d5553acabe01d3e03b4cbf3050a54en" +
  10.                 "5f67fc6c0b8e73c39188cea354bb31eb85008ae1b6c51c16743eb9f5ef229159n");
  11.  
  12.         String keyA = convertToBinary("YAMEK");
  13.         String cipherA = convertToBinary("8f04ebe8c8c030d2413be892640ebd097455b99cd3f11ea898b0adff9ef20985a2a6a44b81c4e558637170482ee4236fc3e7504f2aeb88e3n" +
  14.                 "8f04ebe8c8c030d2413be892640ebd097455b99cd3f11ea898b0adff9ef20985a2a6a44b81c4e558637170482ee4236fc3e7504f2aeb88e3n" +
  15.                 "8f04ebe8c8c030d2413be892640ebd097455b99cd3f11ea8a0e38e1ded248b33n");
  16.  
  17.         String keyB = convertToBinary("YAMEP");
  18.         String cipherB = convertToBinary("0bcb11158ccf687f92403f7d35365adfc8fada72657c95f7310366c67b8af50b5f839c1f02e11b08dabedaf3ccfd8ae07125640ab29265ban" +
  19.                 "0bcb11158ccf687f92403f7d35365adfc8fada72657c95f7310366c67b8af50b5f839c1f02e11b08dabedaf3ccfd8ae07125640ab29265ban" +
  20.                 "0bcb11158ccf687f92403f7d35365adfc8fada72657c95f78572d9759e58a655n");
  21.  
  22.         String keyC = convertToBinary("YAMON");
  23.         String cipherC = convertToBinary("7b4c8b41d78a32f0aba8c10ac0411e3bf97cb2a284bedcd0d9350bc9cb67fc9438bc6fc383ebf50f35f28c2ecd2e280b677b78fb0806146fn" +
  24.                 "7b4c8b41d78a32f0aba8c10ac0411e3bf97cb2a284bedcd0d9350bc9cb67fc9438bc6fc383ebf50f35f28c2ecd2e280b677b78fb0806146fn" +
  25.                 "7b4c8b41d78a32f0aba8c10ac0411e3bf97cb2a284bedcd0908631f438a5a597n");
  26.  
  27.         check(keyA, cipherA);
  28.         check(keyB, cipherB);
  29.         check(keyC, cipherC);
  30.  
  31.     }
  32.  
  33.     private static String convertToBinary(String text) {
  34.         StringBuilder builder = new StringBuilder();
  35.         char[] textChars = text.toCharArray();
  36.         for (char c : textChars) {
  37.             builder.append(Integer.toBinaryString(c));
  38.         }
  39.         return builder.toString();
  40.     }
  41.  
  42.     private static void check(String key, String cipher) {
  43.         int keyDifferent = 0;
  44.         int cipherDifferent = 0;
  45.  
  46.         for(int i=0;i<mainKey.length();i++){
  47.             if(mainKey.charAt(i)!=key.charAt(i)){
  48.                 keyDifferent++;
  49.             }
  50.         }
  51.  
  52.         for(int i=0;i<mainCipher.length();i++){
  53.             if(i>=cipher.length()) break;
  54.             if(mainCipher.charAt(i)!=cipher.charAt(i)){
  55.                 cipherDifferent++;
  56.             }
  57.         }
  58.         System.out.println("KEY: " + keyDifferent);
  59.         System.out.println("CIPHER: " + cipherDifferent);
  60.     }
  61. }