title: C++ OpenSSL HMACSHA1 works but not how I want it to
body: <p>This HMACSHA1 code below works for converting "Password" and "Message" to <code>AFF791FA574D564C83F6456CC198CBD316949DC9</code> as evidence by <a href="http://buchananweb.co.uk/security01.aspx" rel="nofollow">http://buchananweb.co.uk/security01.aspx</a>.  </p>
  
  <p>My question is, Is it possible to have:</p>
  
  <pre><code>BYTE HMAC[] = {0x50,0x61,0x73,0x73,0x77,0x6F,0x72,0x64};
  BYTE data2[] = {0x4D,0x65,0x73,0x73,0x61,0x67,0x65};
  </code></pre>
  
  <p>And still get the same value: <code>AFF791FA574D564C83F6456CC198CBD316949DC9</code>.</p>
  
  <p>For example, if I was on a server and received the packet:</p>
  
  <pre><code>[HEADER] 08 50 61 73 73 77 6F 72 64 00
  [HEADER] 07 4D 65 73 73 61 67 65 00
  </code></pre>
  
  <p>And I rip <code>50 61 73 73 77 6F 72 64</code> &amp; <code>4D 65 73 73 61 67 65</code> from the packet and used this for my HMACSHA1.  How would I go about doing that to get the correct HMACSHA1 value?</p>
  
  <pre><code>    BYTE HMAC[] = "Password";
      BYTE data2[] = "Message";
      //BYTE HMAC[] = {0x50,0x61,0x73,0x73,0x77,0x6F,0x72,0x64};
      //BYTE data2[] = {0x4D,0x65,0x73,0x73,0x61,0x67,0x65};
      HMAC_CTX ctx;
      result = (unsigned char*) malloc(sizeof(char) * result_len);
      ENGINE_load_builtin_engines();
      ENGINE_register_all_complete();
      HMAC_CTX_init(&amp;ctx);
      HMAC_Init_ex(&amp;ctx, HMAC, strlen((const char*)HMAC), EVP_sha1(), NULL);
      HMAC_Update(&amp;ctx, data2, strlen((const char*)(data2)));
      HMAC_Final(&amp;ctx, result, &amp;result_len);
      HMAC_CTX_cleanup(&amp;ctx);
  
      std::cout &lt;&lt; "\n\n";
  
  
   for(int i=0;i&lt;result_len;i++)
      std::cout &lt;&lt; setfill('0') &lt;&lt; setw(2) &lt;&lt; hex &lt;&lt; (int)result[i];
  
      int asd;
      std::cin &gt;&gt; asd;
  // AFF791FA574D564C83F6456CC198CBD316949DC9
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>It works by doing this:</p>
  
  <pre><code>BYTE HMAC[] = {0x50,0x61,0x73,0x73,0x77,0x6F,0x72,0x64, 0x00};
  BYTE data2[] = {0x4D,0x65,0x73,0x73,0x61,0x67,0x65, 0x00};
  </code></pre>
  
  <p>By adding 0x00, at the end.  But, my question is more towards ripping it from data, and using it... would it still be fine?</p>