title: SHA1 Message digest to plain-text
body: <p>How can I turn my message digest into plain-text (getting the original message back). I compute a message digest using the following function. The SHA1 code can be found in <a href="https://github.com/tylabs/quicksand_lite/blob/master/sha1.c" rel="nofollow noreferrer">https://github.com/tylabs/quicksand_lite/blob/master/sha1.c</a> I can not find a function that will make the conversion for me. Is there any algorithm that can do this?</p>
  
  <p>I am also trying to decrypt and encrypt messages this is where the problem comes from. </p>
  
  <pre><code>int main()
  {
  
    char qbits[5];
    char rbits[5];
    char ID[SIZE];   //User ID
    char message[SIZE];   //User message
    char shamessage[SIZE]; //The input message digest(sha1 result)
  
    char xor_result[SIZE]; //Sender XOR result---V
    char xor_result_receiver[SIZE];  //Receiver XOR result
    memset(xor_result, 0, sizeof(char)*SIZE);
    memset(xor_result_receiver, 0, sizeof(char)*SIZE);
  
  
    pairing_t pairing;   //The pair of bilinear map
  
    element_t P, Ppub, s, U, Qid, Sid;
    mpz_t messagehash;
    mpz_init(messagehash);
  
    printf("\n############SETUP############\n");
      printf("Please enter rbits:");
    scanf("%[0-9]", rbits);
      getchar();
    printf("\nPlease enter qbits:");
    scanf("%[0-9]", qbits);
      getchar();
  
    setup_sys(atoi(rbits), atoi(qbits), P, Ppub, pairing, s);
    printf("System parameters have been set!\n");
    element_printf("P = %B\n", P);
    element_printf("Ppub = %B\n", Ppub);
  
  
      printf("###########EXTRACT###########\n");
      element_init_G1(Qid, pairing);
    element_init_G1(Sid, pairing);
    printf("Plase enter your ID:");
    scanf("%[ a-zA-Z0-9+*-!.,&amp;*@{}$#]", ID);
    printf("\nID=%s\n", ID);
      getchar();
      get_private_key(ID, pairing, s, Sid);
    get_public_key(ID, pairing, Qid);
    printf("##########ENCRPTION##########\n");
      printf("\nPlase enter the message to encrypt:");
    scanf("%[ a-zA-Z0-9+*-!.,&amp;*@{}$#]", message);
    getchar();
    printf("The original message=%s", message);
  
      sha_fun(message, shamessage);   //Get the message digest
    printf("\nThe message hash=%s\n", shamessage);
  
      element_init_G1(U, pairing);
    encryption(shamessage, ID, P, Ppub, U, xor_result, pairing);
    printf("Send &lt;U,V&gt; to the receiver!\n");
  
    printf("##########DECRYPTION##########");
    decryption(Sid, pairing, U, xor_result, xor_result_receiver);
    printf("\nThe recovery message digest is %s\n", xor_result_receiver);
    printf("The original message digest is %s\n", shamessage);
  
    if (strcmp(xor_result_receiver, shamessage) == 0) {
  
      printf("Yeah!The message has been decrpted!\n");
    }
  
    else {
      printf("Oops!The message can not be decrpted!\n");
    }
  
    //Free space
    element_clear(P);
    element_clear(Ppub);
    element_clear(Qid);
    element_clear(Sid);
    element_clear(U);
    element_clear(s);
    pairing_clear(pairing);
  
    return 0;
  }
  </code></pre>
  
  <p>And my output is a message digest but I need it to be plain-text. </p>
  
  <pre><code>############SETUP############
  Please enter rbits:6
  
  Please enter qbits:6
  System parameters have been set!
  P = [456, 103]
  Ppub = [176, 88]
  ###########EXTRACT###########
  Plase enter your ID:friedrich12
  
  ID=friedrich12
  Private key Sid = [184, 383]
  
  Public key Qid = [99, 84]
  ##########ENCRPTION##########
  
  Plase enter the message to encrypt:code
  The original message=code
  The message hash=E6FB06210FAFC02FD7479DDBED2D042CC3A5155E
  U = [456, 103]
  Public key Qid = [99, 84]
  
  V=3D958162F64322BFC65D7655DFE6B61D89945F35
  Send &lt;U,V&gt; to the receiver!
  ##########DECRYPTION##########
  The recovery message digest is E6FB06210FAFC02FD7479DDBED2D042CC3A5155E
  The original message digest is E6FB06210FAFC02FD7479DDBED2D042CC3A5155E
  Yeah!The message has been decrpted!
  </code></pre>