title: SHA return different result i MariaDB
body: <p>I have a table that is filled with some value, for setting the value I use a stored procedure that also calculate a hash function and save in database.
  In case of updating value hash should be recalculated. For recalculating hash I use the following procedure:</p>
  
  <pre><code>DELIMITER $$
  CREATE PROCEDURE `sp_UpdateHash`(IN rkey int)
  Begin
  DECLARE AuthCode VarChar(10);
  
  SET @input = concat('SELECT r_ac into @AuthCode
      FROM table_rec
      where r_key=',rkey);
  
  PREPARE squery FROM @input;
  EXECUTE squery;
  SET @hashed = SHA2(@AuthCode,256);
  select @hashed;
  DEALLOCATE PREPARE squery;
  end;
  </code></pre>
  
  <p>and procedure just for calculating hash:</p>
  
  <pre><code>CREATE PROCEDURE `sp_GetHash`(IN AuthCode VarChar(10))
  BEGIN
      DECLARE hashed VarChar(64);
      SET hashed = SHA2(AuthCode,256);
      select hashed as 'Hash';
  END
  </code></pre>
  
  <p>AuthCode identical, but hash is different when I try to process value after select command I get a wrong code. If I compare two hashes with other results, for example from an online generator, the result is similar to the second function: sp_GetHash</p>
  
  <p>Do you have any idea why?</p>