Better validation to prevent segfault in php-scrypt (see https://github.com/DomBlack/php-scrypt/issues/31)