Results 1 to 6 of 6

Thread: QCryptographicHash

  1. #1
    Join Date
    Nov 2007
    Posts
    15
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default QCryptographicHash

    Hi,

    QByteArray l_byteArray = "hello world";

    QCryptographicHash l_crpto( QCryptographicHash::Md5) ;

    l_crpto.addData(l_byteArray);

    l_byteArray = l_crpto.result();

    qDebug<<l_byteArray ; //^╢;╗α▲ε╨?╦"╗Ã…Z═├

    again how to convert hash value to bytearray like l_byteArray = "HELLOWORD";

    Thanks in advance

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QCryptographicHash

    You can use QByteArray::toHex() to obtain hexadecimal representation of the hash, like is shown at http://wiki.qtcentre.org/index.php?title=Cryptography.
    J-P Nurmi

  3. #3
    Join Date
    Nov 2007
    Posts
    15
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QCryptographicHash

    Thanks for reply jpn

    but i want text format conversion like l_byteArray = "hello world";

    is there way to convert above format in qt?

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QCryptographicHash

    But MD5 is a one-way hash..
    J-P Nurmi

  5. #5
    Join Date
    Jun 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QCryptographicHash

    Hello all !!
    Im noob...
    how do this
    i have mysql database with table that contain user passwords encrypted by md5
    my form have QLineEdit for password but method text() return QString and i cant use
    QCryptographicHash pass(QCryptographicHash::Md5);
    pass.addData(passwd->text());
    what i can do ?

  6. #6
    Join Date
    Jun 2008
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: QCryptographicHash

    pass.result().toHex() - you get md5 string (QByteArray, to be precise) of password entered into the box.
    Then you compare that string to the password, which you acquire from the database.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.