title: Mysql encrypt sometimes returns null
body: <p>Why the first and last command line returns null??</p>
  
  <pre><code>$ mysql -u root -ppass -Bse "SELECT ENCRYPT('p@ssW0rd', 'ñsñsñsñ');"
  NULL
  $ mysql -u root -ppass -Bse "SELECT ENCRYPT('p@ssW0rd', 'dafdadsfe');"
  dac0rB9hTC86M
  $ mysql -u root -ppass -Bse "SELECT ENCRYPT('p@ssW0rd', 'dafdadsfeñññ');"
  dac0rB9hTC86M
  $ mysql -u root -ppass -Bse "SELECT ENCRYPT('p@ssW0rd', CONCAT('6', SUBSTRING(SHA(RAND()), -16)));"
  63YRpxd2B8u1A
  $ mysql -u root -ppass -Bse "SELECT ENCRYPT('p@ssW0rd', CONCAT('$6', SUBSTRING(SHA(RAND()), -16)));"
  c7hTUIQiUwO02
  $ mysql -u root -ppass -Bse "SELECT ENCRYPT('p@ssW0rd', CONCAT('$6$', SUBSTRING(SHA(RAND()), -16)));"
  NULL
  </code></pre>
  
  <p>I've also executed:</p>
  
  <pre><code>$ mysql -u root -ppass -Bse "SELECT CONCAT('$6$', SUBSTRING(SHA(RAND()), -16));"
  $7b07151fc5373796
  </code></pre>
  
  <p>And then here it comes the magic:</p>
  
  <pre><code>MariaDB [(none)]&gt; SELECT ENCRYPT('p@ssW0rd', 'ñsñsñsñ');
  +------------------------------------+
  | ENCRYPT('p@ssW0rd', 'ñsñsñsñ')     |
  +------------------------------------+
  | NULL                               |
  +------------------------------------+
  1 row in set (0.00 sec)
  
  MariaDB [(none)]&gt; SELECT ENCRYPT('p@ssW0rd', CONCAT('$6$', SUBSTRING(SHA(RAND()), -16)));
  +------------------------------------------------------------------------------------------------------------+
  | ENCRYPT('p@ssW0rd', CONCAT('$6$', SUBSTRING(SHA(RAND()), -16)))                                            |
  +------------------------------------------------------------------------------------------------------------+
  | $6$0edfe4f3541e5035$kYDyVhQ2sEHDlZE2GsNX0s2Xstg8z7Mj.D3ly.A0DzItg/5WIGoZldKQ0uSiaW9X/ljmmjGbWkMJwsY/WZ4/p. |
  +------------------------------------------------------------------------------------------------------------+
  1 row in set (0.00 sec)
  </code></pre>
  
  <p>This is very annoying as I would like to insert from command line into a table which has password field not null:</p>
  
  <pre><code>$ mysql -u root -ppass  -Bse "INSERT INTO servermail.virtual_users (id, domain_id, password , email) VALUES ('1', '1', ENCRYPT('s1perP@$$', CONCAT('$6$', SUBSTRING(SHA(RAND()), -16))), 'new@user.com');"
  ERROR 1048 (23000) at line 1: Column 'password' cannot be null
  $ "INSERT INTO servermail.virtual_users (id, domain_id, password , email) VALUES ('1', '1', ENCRYPT('s1perP@$$', CONCAT('$6$', SUBSTRING(SHA(RAND()), -16))), 'new@user.com');" | mysql -u root -ppass
  ERROR 1048 (23000) at line 1: Column 'password' cannot be null
  </code></pre>