diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-11-12 08:02:05 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-11-12 08:02:05 (GMT) |
commit | 67e42ba2eb8ab2115e929791cb67a8e9ba413e80 (patch) | |
tree | f2d3b38c76c858e6012b6b6c1b9ecb128be3db04 /src/declarative/qml/qmlengine.cpp | |
parent | 8905d8445dfe8977441302003fa21dde140fa0fe (diff) | |
download | Qt-67e42ba2eb8ab2115e929791cb67a8e9ba413e80.zip Qt-67e42ba2eb8ab2115e929791cb67a8e9ba413e80.tar.gz Qt-67e42ba2eb8ab2115e929791cb67a8e9ba413e80.tar.bz2 |
Qt.md5() method
Diffstat (limited to 'src/declarative/qml/qmlengine.cpp')
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 177818f..53febf5 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -88,6 +88,7 @@ #include <private/qmllistscriptclass_p.h> #include <QtDeclarative/qmlscriptstring.h> #include <private/qmlglobal_p.h> +#include <QtCore/qcryptographichash.h> #ifdef Q_OS_WIN // for %APPDATA% #include "qt_windows.h" @@ -150,6 +151,7 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) qtObject.setProperty(QLatin1String("closestAngle"), scriptEngine.newFunction(QmlEnginePrivate::closestAngle, 2)); qtObject.setProperty(QLatin1String("playSound"), scriptEngine.newFunction(QmlEnginePrivate::playSound, 1)); qtObject.setProperty(QLatin1String("openUrlExternally"),scriptEngine.newFunction(desktopOpenUrl, 1)); + qtObject.setProperty(QLatin1String("md5"),scriptEngine.newFunction(md5, 1)); scriptEngine.globalObject().setProperty(QLatin1String("createQmlObject"), scriptEngine.newFunction(QmlEnginePrivate::createQmlObject, 1)); @@ -816,6 +818,18 @@ QScriptValue QmlEnginePrivate::desktopOpenUrl(QScriptContext *ctxt, QScriptEngin return e->newVariant(QVariant(ret)); } +QScriptValue QmlEnginePrivate::md5(QScriptContext *ctxt, QScriptEngine *e) +{ + QByteArray data; + + if (ctxt->argumentCount() >= 1) + data = ctxt->argument(0).toString().toUtf8(); + + QByteArray result = QCryptographicHash::hash(data, QCryptographicHash::Md5); + + return QScriptValue(QLatin1String(result.toHex())); +} + QScriptValue QmlEnginePrivate::closestAngle(QScriptContext *ctxt, QScriptEngine *e) { if(ctxt->argumentCount() < 2) |