mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
rewrite functions. Only hash(string, method), md5(string) and sha256(string) are available now
This commit is contained in:
parent
ba7770c7cc
commit
3b9c240ba7
@ -1,5 +0,0 @@
|
||||
{
|
||||
"name": "Hash",
|
||||
"type": "group",
|
||||
"description": "This group contains functions to hash values."
|
||||
}
|
42
resources/function_help/json/hash
Normal file
42
resources/function_help/json/hash
Normal file
@ -0,0 +1,42 @@
|
||||
|
||||
{
|
||||
"name": "hash",
|
||||
"type": "function",
|
||||
"description": "Creates a hash from a string with a given method.",
|
||||
"variableLenArguments": false,
|
||||
"arguments": [
|
||||
{"arg":"string", "description": "the string to hash"}, {"arg":"method",
|
||||
"description": "The hash method among 'md4', 'md5', 'sha1', 'sha224', 'sha384', 'sha512', 'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512', 'keccak_224', 'keccak_256', 'keccak_384', 'keccak_512'"}],
|
||||
"examples": [
|
||||
{ "expression":"md4('QGIS')",
|
||||
"returns":"'c0fc71c241cdebb6e888cbac0e2b68eb'"},
|
||||
{ "expression":"md5('QGIS')",
|
||||
"returns":"'57470aaa9e22adaefac7f5f342f1c6da'"},
|
||||
{ "expression":"sha1('QGIS')",
|
||||
"returns":"'f87cfb2b74cdd5867db913237024e7001e62b114'"},
|
||||
{ "expression":"sha224('QGIS')",
|
||||
"returns":"'4093a619ada631c770f44bc643ead18fb393b93d6a6af1861fcfece0'"},
|
||||
{ "expression":"sha256('QGIS')",
|
||||
"returns":"'eb045cba7a797aaa06ac58830846e40c8e8c780bc0676d3393605fae50c05309'"},
|
||||
{ "expression":"sha384('QGIS')",
|
||||
"returns":"'91c1de038cc3d09fdd512e99f9dd9922efadc39ed21d3922e69a4305cc25506033aee388e554b78714c8734f9cd7e610'"},
|
||||
{ "expression":"sha512('QGIS')",
|
||||
"returns":"'c2c092f2ab743bf8edbeb6d028a745f30fc720408465ed369421f0a4e20fa5e27f0c90ad72d3f1d836eaa5d25cd39897d4cf77e19984668ef58da6e3159f18ac'"},
|
||||
{ "expression":"sha3_224('QGIS')",
|
||||
"returns":"'467f49a5039e7280d5d42fd433e80d203439e338eaabd701f0d6c17d'"},
|
||||
{ "expression":"sha3_256('QGIS')",
|
||||
"returns":"'540f7354b6b8a6e735f2845250f15f4f3ba4f666c55574d9e9354575de0e980f'"},
|
||||
{ "expression":"sha3_384('QGIS')",
|
||||
"returns":"'96052da1e77679e9a65f60d7ead961b287977823144786386eb43647b0901fd8516fa6f1b9d243fb3f28775e6dde6107'"},
|
||||
{ "expression":"sha3_512('QGIS')",
|
||||
"returns":"'900d079dc69761da113980253aa8ac0414a8bd6d09879a916228f8743707c4758051c98445d6b8945ec854ff90655005e02aceb0a2ffc6a0ebf818745d665349'"},
|
||||
{ "expression":"keccak_224('QGIS')",
|
||||
"returns":"'5b0ce6acef8b0a121d4ac4f3eaa8503c799ad4e26a3392d1fb201478'"},
|
||||
{ "expression":"keccak_256('QGIS')",
|
||||
"returns":"'991c520aa6815392de24087f61b2ae0fd56abbfeee4a8ca019c1011d327c577e'"},
|
||||
{ "expression":"keccak_384('QGIS')",
|
||||
"returns":"'c57a3aed9d856fa04e5eeee9b62b6e027cca81ba574116d3cc1f0d48a1ef9e5886ff463ea8d0fac772ee473bf92f810d'"},
|
||||
{ "expression":"keccak_512('QGIS')",
|
||||
"returns":"'6f0f751776b505e317de222508fa5d3ed7099d8f07c74fed54ccee6e7cdc6b89b4a085e309f2ee5210c9'"}
|
||||
]
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
|
||||
{
|
||||
"name": "keccak_224",
|
||||
"type": "function",
|
||||
"description": "Creates a keccak_224 hash from a string.",
|
||||
"variableLenArguments": false,
|
||||
"arguments": [
|
||||
{"arg":"string", "description": "the string to hash"}],
|
||||
"examples": [ { "expression":"keccak_224('QGIS')", "returns":"'5b0ce6acef8b0a121d4ac4f3eaa8503c799ad4e26a3392d1fb201478'"}
|
||||
]
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
|
||||
{
|
||||
"name": "keccak_256",
|
||||
"type": "function",
|
||||
"description": "Creates a keccak_256 hash from a string.",
|
||||
"variableLenArguments": false,
|
||||
"arguments": [
|
||||
{"arg":"string", "description": "the string to hash"}],
|
||||
"examples": [ { "expression":"keccak_256('QGIS')", "returns":"'991c520aa6815392de24087f61b2ae0fd56abbfeee4a8ca019c1011d327c577e'"}
|
||||
]
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
|
||||
{
|
||||
"name": "keccak_384",
|
||||
"type": "function",
|
||||
"description": "Creates a keccak_384 hash from a string.",
|
||||
"variableLenArguments": false,
|
||||
"arguments": [
|
||||
{"arg":"string", "description": "the string to hash"}],
|
||||
"examples": [ { "expression":"keccak_384('QGIS')", "returns":"'c57a3aed9d856fa04e5eeee9b62b6e027cca81ba574116d3cc1f0d48a1ef9e5886ff463ea8d0fac772ee473bf92f810d'"}
|
||||
]
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
|
||||
{
|
||||
"name": "keccak_512",
|
||||
"type": "function",
|
||||
"description": "Creates a keccak_512 hash from a string.",
|
||||
"variableLenArguments": false,
|
||||
"arguments": [
|
||||
{"arg":"string", "description": "the string to hash"}],
|
||||
"examples": [ { "expression":"keccak_512('QGIS')", "returns":"'6f0f751776b505e317de222508fa5d3ed7099d8f07c74fed54ccee6e7cdc6b89b4a085e309f2ee5210c942bbeb142bdfe48f84f912e0f3f41bdbf47110c2d344'"}
|
||||
]
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
|
||||
{
|
||||
"name": "md4",
|
||||
"type": "function",
|
||||
"description": "Creates a md4 hash from a string.",
|
||||
"variableLenArguments": false,
|
||||
"arguments": [
|
||||
{"arg":"string", "description": "the string to hash"}],
|
||||
"examples": [ { "expression":"md4('QGIS')", "returns":"'c0fc71c241cdebb6e888cbac0e2b68eb'"}
|
||||
]
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
|
||||
{
|
||||
"name": "sha1",
|
||||
"type": "function",
|
||||
"description": "Creates a sha1 hash from a string.",
|
||||
"variableLenArguments": false,
|
||||
"arguments": [
|
||||
{"arg":"string", "description": "the string to hash"}],
|
||||
"examples": [ { "expression":"sha1('QGIS')", "returns":"'f87cfb2b74cdd5867db913237024e7001e62b114'"}
|
||||
]
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
|
||||
{
|
||||
"name": "sha224",
|
||||
"type": "function",
|
||||
"description": "Creates a sha224 hash from a string.",
|
||||
"variableLenArguments": false,
|
||||
"arguments": [
|
||||
{"arg":"string", "description": "the string to hash"}],
|
||||
"examples": [ { "expression":"sha224('QGIS')", "returns":"'4093a619ada631c770f44bc643ead18fb393b93d6a6af1861fcfece0'"}
|
||||
]
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
|
||||
{
|
||||
"name": "sha384",
|
||||
"type": "function",
|
||||
"description": "Creates a sha384 hash from a string.",
|
||||
"variableLenArguments": false,
|
||||
"arguments": [
|
||||
{"arg":"string", "description": "the string to hash"}],
|
||||
"examples": [ { "expression":"sha384('QGIS')", "returns":"'91c1de038cc3d09fdd512e99f9dd9922efadc39ed21d3922e69a4305cc25506033aee388e554b78714c8734f9cd7e610'"}
|
||||
]
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
|
||||
{
|
||||
"name": "sha3_224",
|
||||
"type": "function",
|
||||
"description": "Creates a sha3_224 hash from a string.",
|
||||
"variableLenArguments": false,
|
||||
"arguments": [
|
||||
{"arg":"string", "description": "the string to hash"}],
|
||||
"examples": [ { "expression":"sha3_224('QGIS')", "returns":"'467f49a5039e7280d5d42fd433e80d203439e338eaabd701f0d6c17d'"}
|
||||
]
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
|
||||
{
|
||||
"name": "sha3_256",
|
||||
"type": "function",
|
||||
"description": "Creates a sha3_256 hash from a string.",
|
||||
"variableLenArguments": false,
|
||||
"arguments": [
|
||||
{"arg":"string", "description": "the string to hash"}],
|
||||
"examples": [ { "expression":"sha3_256('QGIS')", "returns":"'540f7354b6b8a6e735f2845250f15f4f3ba4f666c55574d9e9354575de0e980f'"}
|
||||
]
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
|
||||
{
|
||||
"name": "sha3_384",
|
||||
"type": "function",
|
||||
"description": "Creates a sha3_384 hash from a string.",
|
||||
"variableLenArguments": false,
|
||||
"arguments": [
|
||||
{"arg":"string", "description": "the string to hash"}],
|
||||
"examples": [ { "expression":"sha3_384('QGIS')", "returns":"'96052da1e77679e9a65f60d7ead961b287977823144786386eb43647b0901fd8516fa6f1b9d243fb3f28775e6dde6107'"}
|
||||
]
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
|
||||
{
|
||||
"name": "sha3_512",
|
||||
"type": "function",
|
||||
"description": "Creates a sha3_512 hash from a string.",
|
||||
"variableLenArguments": false,
|
||||
"arguments": [
|
||||
{"arg":"string", "description": "the string to hash"}],
|
||||
"examples": [ { "expression":"sha3_512('QGIS')", "returns":"'900d079dc69761da113980253aa8ac0414a8bd6d09879a916228f8743707c4758051c98445d6b8945ec854ff90655005e02aceb0a2ffc6a0ebf818745d665349'"}
|
||||
]
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
|
||||
{
|
||||
"name": "sha512",
|
||||
"type": "function",
|
||||
"description": "Creates a sha512 hash from a string.",
|
||||
"variableLenArguments": false,
|
||||
"arguments": [
|
||||
{"arg":"string", "description": "the string to hash"}],
|
||||
"examples": [ { "expression":"sha512('QGIS')", "returns":"'c2c092f2ab743bf8edbeb6d028a745f30fc720408465ed369421f0a4e20fa5e27f0c90ad72d3f1d836eaa5d25cd39897d4cf77e19984668ef58da6e3159f18ac'"}
|
||||
]
|
||||
}
|
@ -4993,12 +4993,77 @@ static QVariant fcnFileSize( const QVariantList &values, const QgsExpressionCont
|
||||
|
||||
static QVariant fcnHash( const QString str, const QCryptographicHash::Algorithm algorithm )
|
||||
{
|
||||
|
||||
return QString( QCryptographicHash::hash( str.toUtf8(), algorithm ).toHex() );
|
||||
}
|
||||
|
||||
static QVariant fcnHashMd4( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
||||
static QVariant fcnGenericHash( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
||||
{
|
||||
return fcnHash( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), QCryptographicHash::Md4 );
|
||||
QVariant hash;
|
||||
QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
|
||||
QString method = QgsExpressionUtils::getStringValue( values.at( 1 ), parent ).toLower();
|
||||
|
||||
if ( method == QString( "md4" ) )
|
||||
{
|
||||
hash = fcnHash( str, QCryptographicHash::Md4 );
|
||||
}
|
||||
else if ( method == QString( "md5" ) )
|
||||
{
|
||||
hash = fcnHash( str, QCryptographicHash::Md5 );
|
||||
}
|
||||
else if ( method == QString( "sha1" ) )
|
||||
{
|
||||
hash = fcnHash( str, QCryptographicHash::Sha1 );
|
||||
}
|
||||
else if ( method == QString( "sha224" ) )
|
||||
{
|
||||
hash = fcnHash( str, QCryptographicHash::Sha224 );
|
||||
}
|
||||
else if ( method == QString( "sha256" ) )
|
||||
{
|
||||
hash = fcnHash( str, QCryptographicHash::Sha256 );
|
||||
}
|
||||
else if ( method == QString( "sha384" ) )
|
||||
{
|
||||
hash = fcnHash( str, QCryptographicHash::Sha384 );
|
||||
}
|
||||
else if ( method == QString( "sha512" ) )
|
||||
{
|
||||
hash = fcnHash( str, QCryptographicHash::Sha512 );
|
||||
}
|
||||
else if ( method == QString( "sha3_224" ) )
|
||||
{
|
||||
hash = fcnHash( str, QCryptographicHash::Sha3_224 );
|
||||
}
|
||||
else if ( method == QString( "sha3_256" ) )
|
||||
{
|
||||
hash = fcnHash( str, QCryptographicHash::Sha3_256 );
|
||||
}
|
||||
else if ( method == QString( "sha3_384" ) )
|
||||
{
|
||||
hash = fcnHash( str, QCryptographicHash::Sha3_384 );
|
||||
}
|
||||
else if ( method == QString( "sha3_512" ) )
|
||||
{
|
||||
hash = fcnHash( str, QCryptographicHash::Sha3_512 );
|
||||
}
|
||||
else if ( method == QString( "keccak_224" ) )
|
||||
{
|
||||
hash = fcnHash( str, QCryptographicHash::Keccak_224 );
|
||||
}
|
||||
else if ( method == QString( "keccak_256" ) )
|
||||
{
|
||||
hash = fcnHash( str, QCryptographicHash::Keccak_256 );
|
||||
}
|
||||
else if ( method == QString( "keccak_384" ) )
|
||||
{
|
||||
hash = fcnHash( str, QCryptographicHash::Keccak_384 );
|
||||
}
|
||||
else if ( method == QString( "keccak_512" ) )
|
||||
{
|
||||
hash = fcnHash( str, QCryptographicHash::Keccak_512 );
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
static QVariant fcnHashMd5( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
||||
@ -5006,71 +5071,11 @@ static QVariant fcnHashMd5( const QVariantList &values, const QgsExpressionConte
|
||||
return fcnHash( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), QCryptographicHash::Md5 );
|
||||
}
|
||||
|
||||
static QVariant fcnHashSha1( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
||||
{
|
||||
return fcnHash( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), QCryptographicHash::Sha1 );
|
||||
}
|
||||
|
||||
static QVariant fcnHashSha224( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
||||
{
|
||||
return fcnHash( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), QCryptographicHash::Sha224 );
|
||||
}
|
||||
|
||||
static QVariant fcnHashSha256( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
||||
{
|
||||
return fcnHash( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), QCryptographicHash::Sha256 );
|
||||
}
|
||||
|
||||
static QVariant fcnHashSha384( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
||||
{
|
||||
return fcnHash( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), QCryptographicHash::Sha384 );
|
||||
}
|
||||
|
||||
static QVariant fcnHashSha512( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
||||
{
|
||||
return fcnHash( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), QCryptographicHash::Sha512 );
|
||||
}
|
||||
|
||||
static QVariant fcnHashSha3_224( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
||||
{
|
||||
return fcnHash( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), QCryptographicHash::Sha3_224 );
|
||||
}
|
||||
|
||||
static QVariant fcnHashSha3_256( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
||||
{
|
||||
return fcnHash( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), QCryptographicHash::Sha3_256 );
|
||||
}
|
||||
|
||||
static QVariant fcnHashSha3_384( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
||||
{
|
||||
return fcnHash( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), QCryptographicHash::Sha3_384 );
|
||||
}
|
||||
|
||||
static QVariant fcnHashSha3_512( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
||||
{
|
||||
return fcnHash( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), QCryptographicHash::Sha3_512 );
|
||||
}
|
||||
|
||||
static QVariant fcnHashKeccak_224( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
||||
{
|
||||
return fcnHash( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), QCryptographicHash::Keccak_224 );
|
||||
}
|
||||
|
||||
static QVariant fcnHashKeccak_256( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
||||
{
|
||||
return fcnHash( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), QCryptographicHash::Keccak_256 );
|
||||
}
|
||||
|
||||
static QVariant fcnHashKeccak_384( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
||||
{
|
||||
return fcnHash( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), QCryptographicHash::Keccak_384 );
|
||||
}
|
||||
|
||||
static QVariant fcnHashKeccak_512( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
||||
{
|
||||
return fcnHash( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), QCryptographicHash::Keccak_512 );
|
||||
}
|
||||
|
||||
const QList<QgsExpressionFunction *> &QgsExpression::Functions()
|
||||
{
|
||||
// The construction of the list isn't thread-safe, and without the mutex,
|
||||
@ -5366,36 +5371,12 @@ const QList<QgsExpressionFunction *> &QgsExpression::Functions()
|
||||
fcnFileSize, QStringLiteral( "Files and Paths" ) )
|
||||
|
||||
// hash
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "md4" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "string" ) ),
|
||||
fcnHashMd4, QStringLiteral( "Hash" ) )
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "hash" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral( "method" ) ),
|
||||
fcnGenericHash, QStringLiteral( "Conversions" ) )
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "md5" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "string" ) ),
|
||||
fcnHashMd5, QStringLiteral( "Hash" ) )
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "sha1" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "string" ) ),
|
||||
fcnHashSha1, QStringLiteral( "Hash" ) )
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "sha224" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "string" ) ),
|
||||
fcnHashSha224, QStringLiteral( "Hash" ) )
|
||||
fcnHashMd5, QStringLiteral( "Conversions" ) )
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "sha256" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "string" ) ),
|
||||
fcnHashSha256, QStringLiteral( "Hash" ) )
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "sha384" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "string" ) ),
|
||||
fcnHashSha384, QStringLiteral( "Hash" ) )
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "sha512" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "string" ) ),
|
||||
fcnHashSha512, QStringLiteral( "Hash" ) )
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "sha3_224" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "string" ) ),
|
||||
fcnHashSha3_224, QStringLiteral( "Hash" ) )
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "sha3_256" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "string" ) ),
|
||||
fcnHashSha3_256, QStringLiteral( "Hash" ) )
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "sha3_384" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "string" ) ),
|
||||
fcnHashSha3_384, QStringLiteral( "Hash" ) )
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "sha3_512" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "string" ) ),
|
||||
fcnHashSha3_512, QStringLiteral( "Hash" ) )
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "keccak_224" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "string" ) ),
|
||||
fcnHashKeccak_224, QStringLiteral( "Hash" ) )
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "keccak_256" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "string" ) ),
|
||||
fcnHashKeccak_256, QStringLiteral( "Hash" ) )
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "keccak_384" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "string" ) ),
|
||||
fcnHashKeccak_384, QStringLiteral( "Hash" ) )
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "keccak_512" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "string" ) ),
|
||||
fcnHashKeccak_512, QStringLiteral( "Hash" ) )
|
||||
fcnHashSha256, QStringLiteral( "Conversions" ) )
|
||||
|
||||
// deprecated stuff - hidden from users
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "$scale" ), QgsExpressionFunction::ParameterList(), fcnMapScale, QStringLiteral( "deprecated" ) );
|
||||
|
@ -1472,36 +1472,26 @@ class TestQgsExpression: public QObject
|
||||
QTest::newRow( "is_file(valid)" ) << QStringLiteral( "is_file('%1')" ).arg( TEST_DATA_DIR ) << false << QVariant( false );
|
||||
|
||||
// hash functions
|
||||
QTest::newRow( "md4(NULL)" ) << QStringLiteral( "md4(NULL)" ) << false << QVariant();
|
||||
QTest::newRow( "md4('QGIS')" ) << QStringLiteral( "md4('QGIS')" ) << false << QVariant( "c0fc71c241cdebb6e888cbac0e2b68eb" );
|
||||
QTest::newRow( "md5(NULL)" ) << QStringLiteral( "md5(NULL)" ) << false << QVariant();
|
||||
QTest::newRow( "md5('QGIS')" ) << QStringLiteral( "md5('QGIS')" ) << false << QVariant( "57470aaa9e22adaefac7f5f342f1c6da" );
|
||||
QTest::newRow( "sha1(NULL)" ) << QStringLiteral( "sha1(NULL)" ) << false << QVariant();
|
||||
QTest::newRow( "sha1('QGIS')" ) << QStringLiteral( "sha1('QGIS')" ) << false << QVariant( "f87cfb2b74cdd5867db913237024e7001e62b114" );
|
||||
QTest::newRow( "sha224(NULL)" ) << QStringLiteral( "sha224(NULL)" ) << false << QVariant();
|
||||
QTest::newRow( "sha224('QGIS')" ) << QStringLiteral( "sha224('QGIS')" ) << false << QVariant( "4093a619ada631c770f44bc643ead18fb393b93d6a6af1861fcfece0" );
|
||||
QTest::newRow( "sha256(NULL)" ) << QStringLiteral( "sha256(NULL)" ) << false << QVariant();
|
||||
QTest::newRow( "sha256(NULL)" ) << QStringLiteral( "sha256(NULL)" ) << false << QVariant( );
|
||||
QTest::newRow( "sha256('QGIS')" ) << QStringLiteral( "sha256('QGIS')" ) << false << QVariant( "eb045cba7a797aaa06ac58830846e40c8e8c780bc0676d3393605fae50c05309" );
|
||||
QTest::newRow( "sha384(NULL)" ) << QStringLiteral( "sha384(NULL)" ) << false << QVariant();
|
||||
QTest::newRow( "sha384('QGIS')" ) << QStringLiteral( "sha384('QGIS')" ) << false << QVariant( "91c1de038cc3d09fdd512e99f9dd9922efadc39ed21d3922e69a4305cc25506033aee388e554b78714c8734f9cd7e610" );
|
||||
QTest::newRow( "sha512(NULL)" ) << QStringLiteral( "sha512(NULL)" ) << false << QVariant();
|
||||
QTest::newRow( "sha512('QGIS')" ) << QStringLiteral( "sha512('QGIS')" ) << false << QVariant( "c2c092f2ab743bf8edbeb6d028a745f30fc720408465ed369421f0a4e20fa5e27f0c90ad72d3f1d836eaa5d25cd39897d4cf77e19984668ef58da6e3159f18ac" );
|
||||
QTest::newRow( "sha3_224(NULL)" ) << QStringLiteral( "sha3_224(NULL)" ) << false << QVariant();
|
||||
QTest::newRow( "sha3_224('QGIS')" ) << QStringLiteral( "sha3_224('QGIS')" ) << false << QVariant( "467f49a5039e7280d5d42fd433e80d203439e338eaabd701f0d6c17d" );
|
||||
QTest::newRow( "sha3_256(NULL)" ) << QStringLiteral( "sha3_256(NULL)" ) << false << QVariant();
|
||||
QTest::newRow( "sha3_256('QGIS')" ) << QStringLiteral( "sha3_256('QGIS')" ) << false << QVariant( "540f7354b6b8a6e735f2845250f15f4f3ba4f666c55574d9e9354575de0e980f" );
|
||||
QTest::newRow( "sha3_384(NULL)" ) << QStringLiteral( "sha3_384(NULL)" ) << false << QVariant();
|
||||
QTest::newRow( "sha3_384('QGIS')" ) << QStringLiteral( "sha3_384('QGIS')" ) << false << QVariant( "96052da1e77679e9a65f60d7ead961b287977823144786386eb43647b0901fd8516fa6f1b9d243fb3f28775e6dde6107" );
|
||||
QTest::newRow( "sha3_512(NULL)" ) << QStringLiteral( "sha3_512(NULL)" ) << false << QVariant();
|
||||
QTest::newRow( "sha3_512('QGIS')" ) << QStringLiteral( "sha3_512('QGIS')" ) << false << QVariant( "900d079dc69761da113980253aa8ac0414a8bd6d09879a916228f8743707c4758051c98445d6b8945ec854ff90655005e02aceb0a2ffc6a0ebf818745d665349" );
|
||||
QTest::newRow( "keccak_224(NULL)" ) << QStringLiteral( "keccak_224(NULL)" ) << false << QVariant();
|
||||
QTest::newRow( "keccak_224('QGIS')" ) << QStringLiteral( "keccak_224('QGIS')" ) << false << QVariant( "5b0ce6acef8b0a121d4ac4f3eaa8503c799ad4e26a3392d1fb201478" );
|
||||
QTest::newRow( "keccak_256(NULL)" ) << QStringLiteral( "keccak_256(NULL)" ) << false << QVariant();
|
||||
QTest::newRow( "keccak_256('QGIS')" ) << QStringLiteral( "keccak_256('QGIS')" ) << false << QVariant( "991c520aa6815392de24087f61b2ae0fd56abbfeee4a8ca019c1011d327c577e" );
|
||||
QTest::newRow( "keccak_384(NULL)" ) << QStringLiteral( "keccak_384(NULL)" ) << false << QVariant();
|
||||
QTest::newRow( "keccak_384('QGIS')" ) << QStringLiteral( "keccak_384('QGIS')" ) << false << QVariant( "c57a3aed9d856fa04e5eeee9b62b6e027cca81ba574116d3cc1f0d48a1ef9e5886ff463ea8d0fac772ee473bf92f810d" );
|
||||
QTest::newRow( "keccak_512(NULL)" ) << QStringLiteral( "keccak_512(NULL)" ) << false << QVariant();
|
||||
QTest::newRow( "keccak_512('QGIS')" ) << QStringLiteral( "keccak_512('QGIS')" ) << false << QVariant( "6f0f751776b505e317de222508fa5d3ed7099d8f07c74fed54ccee6e7cdc6b89b4a085e309f2ee5210c942bbeb142bdfe48f84f912e0f3f41bdbf47110c2d344" );
|
||||
QTest::newRow( "hash('QGIS', 'qsdf')" ) << QStringLiteral( "hash('QGIS', 'qsdf')" ) << false << QVariant();
|
||||
QTest::newRow( "hash('QGIS', 'md4')" ) << QStringLiteral( "hash('QGIS', 'md4')" ) << false << QVariant( "c0fc71c241cdebb6e888cbac0e2b68eb" );
|
||||
QTest::newRow( "hash('QGIS', 'md5')" ) << QStringLiteral( "hash('QGIS', 'md5')" ) << false << QVariant( "57470aaa9e22adaefac7f5f342f1c6da" );
|
||||
QTest::newRow( "hash('QGIS', 'sha1')" ) << QStringLiteral( "hash('QGIS', 'sha1')" ) << false << QVariant( "f87cfb2b74cdd5867db913237024e7001e62b114" );
|
||||
QTest::newRow( "hash('QGIS', 'sha224')" ) << QStringLiteral( "hash('QGIS', 'sha224')" ) << false << QVariant( "4093a619ada631c770f44bc643ead18fb393b93d6a6af1861fcfece0" );
|
||||
QTest::newRow( "hash('QGIS', 'sha256')" ) << QStringLiteral( "hash('QGIS', 'sha256')" ) << false << QVariant( "eb045cba7a797aaa06ac58830846e40c8e8c780bc0676d3393605fae50c05309" );
|
||||
QTest::newRow( "hash('QGIS', 'sha384')" ) << QStringLiteral( "hash('QGIS', 'sha384')" ) << false << QVariant( "91c1de038cc3d09fdd512e99f9dd9922efadc39ed21d3922e69a4305cc25506033aee388e554b78714c8734f9cd7e610" );
|
||||
QTest::newRow( "hash('QGIS', 'sha512')" ) << QStringLiteral( "hash('QGIS', 'sha512')" ) << false << QVariant( "c2c092f2ab743bf8edbeb6d028a745f30fc720408465ed369421f0a4e20fa5e27f0c90ad72d3f1d836eaa5d25cd39897d4cf77e19984668ef58da6e3159f18ac" );
|
||||
QTest::newRow( "hash('QGIS', 'sha3_224')" ) << QStringLiteral( "hash('QGIS', 'sha3_224')" ) << false << QVariant( "467f49a5039e7280d5d42fd433e80d203439e338eaabd701f0d6c17d" );
|
||||
QTest::newRow( "hash('QGIS', 'sha3_256')" ) << QStringLiteral( "hash('QGIS', 'sha3_256')" ) << false << QVariant( "540f7354b6b8a6e735f2845250f15f4f3ba4f666c55574d9e9354575de0e980f" );
|
||||
QTest::newRow( "hash('QGIS', 'sha3_384')" ) << QStringLiteral( "hash('QGIS', 'sha3_384')" ) << false << QVariant( "96052da1e77679e9a65f60d7ead961b287977823144786386eb43647b0901fd8516fa6f1b9d243fb3f28775e6dde6107" );
|
||||
QTest::newRow( "hash('QGIS', 'sha3_512')" ) << QStringLiteral( "hash('QGIS', 'sha3_512')" ) << false << QVariant( "900d079dc69761da113980253aa8ac0414a8bd6d09879a916228f8743707c4758051c98445d6b8945ec854ff90655005e02aceb0a2ffc6a0ebf818745d665349" );
|
||||
QTest::newRow( "hash('QGIS', 'keccak_224')" ) << QStringLiteral( "hash('QGIS', 'keccak_224')" ) << false << QVariant( "5b0ce6acef8b0a121d4ac4f3eaa8503c799ad4e26a3392d1fb201478" );
|
||||
QTest::newRow( "hash('QGIS', 'keccak_256')" ) << QStringLiteral( "hash('QGIS', 'keccak_256')" ) << false << QVariant( "991c520aa6815392de24087f61b2ae0fd56abbfeee4a8ca019c1011d327c577e" );
|
||||
QTest::newRow( "hash('QGIS', 'keccak_384')" ) << QStringLiteral( "hash('QGIS', 'keccak_384')" ) << false << QVariant( "c57a3aed9d856fa04e5eeee9b62b6e027cca81ba574116d3cc1f0d48a1ef9e5886ff463ea8d0fac772ee473bf92f810d" );
|
||||
QTest::newRow( "hash('QGIS', 'keccak_512')" ) << QStringLiteral( "hash('QGIS', 'keccak_512')" ) << false << QVariant( "6f0f751776b505e317de222508fa5d3ed7099d8f07c74fed54ccee6e7cdc6b89b4a085e309f2ee5210c942bbeb142bdfe48f84f912e0f3f41bdbf47110c2d344" );
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user