{"id":2987,"date":"2014-03-13T01:30:25","date_gmt":"2014-03-13T01:30:25","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/13\/gcc-use-openssls-sha256-functions-collection-of-common-programming-errors-2\/"},"modified":"2014-03-13T01:30:25","modified_gmt":"2014-03-13T01:30:25","slug":"gcc-use-openssls-sha256-functions-collection-of-common-programming-errors-2","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/13\/gcc-use-openssls-sha256-functions-collection-of-common-programming-errors-2\/","title":{"rendered":"GCC: Use OpenSSL&#39;s SHA256 Functions-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m writing a program to get myself acquainted with OpenSSL, libncurses, and UDP networking. I decided to work with OpenSSL&#8217;s SHA256 to become familiar with industry encryption standards, but I&#8217;m having issues with getting it working. I&#8217;ve isolated the error to the linking of OpenSSL with the compiled program. I&#8217;m working on Ubuntu 12.10, 64 bit. I have the package libssl-dev installed.<\/p>\n<p>Take, for instance, the C++ main.cpp:<\/p>\n<pre><code>#include \n#include \n#include \n#include \nusing namespace std;\n\n#include \n\nstring sha256(const string str)\n{\n    unsigned char hash[SHA256_DIGEST_LENGTH];\n    SHA256_CTX sha256;\n    SHA256_Init(&amp;sha256);\n    SHA256_Update(&amp;sha256, str.c_str(), str.size());\n    SHA256_Final(hash, &amp;sha256);\n    stringstream ss;\n    for(int i = 0; i &lt; SHA256_DIGEST_LENGTH; i++)\n    {\n        ss<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m writing a program to get myself acquainted with OpenSSL, libncurses, and UDP networking. I decided to work with OpenSSL&#8217;s SHA256 to become familiar with industry encryption standards, but I&#8217;m having issues with getting it working. I&#8217;ve isolated the error to the linking of OpenSSL with the compiled program. I&#8217;m working on Ubuntu 12.10, 64 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2987","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2987","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2987"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2987\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2987"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2987"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2987"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}