Ejemplo n.º 1
0
  public String decHashValue(String Cipher_Chosen, String hashValue) {
    //        System.out.println("Decrypting hash message --" + hashValue);
    String decHashValue = null;

    if (Cipher_Chosen.equalsIgnoreCase("rc4")) {
      RC4 rc4 = new RC4(new String(key1));
      byte[] cipher = hashValue.getBytes();
      byte[] deText = rc4.decrypt(cipher);
      decHashValue = new String(deText);
    } else if (Cipher_Chosen.equalsIgnoreCase("cbc")) {
      CBC cbc = new CBC(key1, key2);
      byte[] enText = hashValue.getBytes();
      decHashValue = cbc.decrypt(enText);
    } else if (Cipher_Chosen.equalsIgnoreCase("pcbc")) {
      PCBC pcbc = new PCBC(key1, key2);
      byte[] enText = hashValue.getBytes();
      decHashValue = pcbc.decrypt(enText);
    } else if (Cipher_Chosen.equalsIgnoreCase("cfb")) {
      // Cipher chosen is CFB
      CFB cfb = new CFB(key1, key2);
      byte[] enText = hashValue.getBytes();
      decHashValue = cfb.decrypt(enText);
    }

    return decHashValue;
  }