title: Using Openssl blowfish encryption algorithm in C++
body: <p>I am writing code to encrypt the passwords and match encypted password to check if the passwords are weak. I have written encryption code using ECB mode API and it is not working as expected. There are few of the questions I am coming to while debugging my code. The only option I see, I can use is BF_ecb_encrypt.</p>
  
  <p>1) ecb mode works on 8bytes at a time. What if my password has less than 8 characters? should it be padded randomly generated char? or with Zero's? Will it work this way? or any other possible way</p>
  
  <p>2) Snippet:</p>
  
  <pre><code>BF_set_key(bfKey, strlen(achSalt), achSalt);
  String strBuf;
  while (len &gt;= 8)
  {
    BF_ecb_encrypt(inStr,buf, bfKey, BF_ENCRYPT);
    len -= 8;
    inStr += 8;
    strBuf += String(reinterpret_cast&lt;const char*&gt;(buf));
    buf +=8;
  }
  </code></pre>
  
  <p>Is there any bug in the code?</p>
  
  <p>Thanks for help in advance.</p>