original_string: public static function digest($data, $hash = null)
      {
          if ($hash===null) {
              $preferred = array(
                  'sha512',
                  'sha384',
                  'sha256',
                  'sha224',
                  'md5'
              );
  
              $hashes = array_intersect($preferred, hash_algos());
  
              if (count($hashes) == 0) {
                  throw new KlarnaException(
                      "No available hash algorithm supported!"
                  );
              }
              $hash = array_shift($hashes);
          }
          self::printDebug('digest() using hash', $hash);
  
          return base64_encode(pack("H*", hash($hash, $data)));
      }
code: public static function digest($data, $hash = null)
      {
          if ($hash===null) {
              $preferred = array(
                  'sha512',
                  'sha384',
                  'sha256',
                  'sha224',
                  'md5'
              );
  
              $hashes = array_intersect($preferred, hash_algos());
  
              if (count($hashes) == 0) {
                  throw new KlarnaException(
                      "No available hash algorithm supported!"
                  );
              }
              $hash = array_shift($hashes);
          }
          self::printDebug('digest() using hash', $hash);
  
          return base64_encode(pack("H*", hash($hash, $data)));
      }
code_tokens: public static function digest ( $ data , $ hash = null ) { if ( $ hash === null ) { $ preferred = array ( 'sha512' , 'sha384' , 'sha256' , 'sha224' , 'md5' ) ; $ hashes = array_intersect ( $ preferred , hash_algos ( ) ) ; if ( count ( $ hashes ) == 0 ) { throw new KlarnaException ( "No available hash algorithm supported!" ) ; } $ hash = array_shift ( $ hashes ) ; } self :: printDebug ( 'digest() using hash' , $ hash ) ; return base64_encode ( pack ( "H*" , hash ( $ hash , $ data ) ) ) ; }
docstring: Creates a digest hash from the inputted string,
  and the specified or the preferred hash algorithm.
  
  @param string $data Data to be hashed.
  @param string $hash hash algoritm to use
  
  @throws KlarnaException
  @return string  Base64 encoded hash.
docstring_tokens: Creates a digest hash from the inputted string and the specified or the preferred hash algorithm .