Results 1 to 1 of 1

Thread: Joomla 1.5 password hash Class 1.0 for QT using C++

  1. #1
    Join Date
    Oct 2009
    Location
    London
    Posts
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Smile Joomla 1.5 password hash Class 1.0 for QT using C++

    Hi All QT Developers

    This is a Class I mad for some Projects.
    I need it Under the Development work in some point.

    I wanted to shear it with you all
    to make use of it in your applications which you may need to
    have access to Joomla Database and Connect it using QT Library.
    using C++.. to work at Windows,Linux, Unix, MAC or Mobiles as will..


    For Example if you have database connected to Joomla 1.5
    and has got the database structure,
    But in your application you need to pass the username and password
    and you need this tool to decrypt the password users type in your applications

    This Class will help you decrypt the password or Create a new password for Joomla.
    if you want your application to add new users to Joomla. so the user will be able to login
    to the site even if they registered using your application.

    As the Application can be downloaded and installed. but in some point we need to verify that user is in our Joomla database or not and the password is correct or not..


    File joomla15passwordhash.h
    Qt Code:
    1. /* Joomla 1.5 password hash Class 1.0
    2.  * Copyright
    3.  * Smart Neural Tech LTD
    4.  * www.smartneural.com
    5.  * rajab@smartneural.com
    6.  *
    7.  * Developer Name: Rajab Natshah
    8.  * rajab@natshah.com
    9.  *
    10.  * This Class helps you use username and passwords
    11.  * from the Joomla 1.5 database Cryptographic Hash using QT Library.
    12.  * And C++ Class.
    13.  *
    14.  */
    15.  
    16. #ifndef JOOMLA15PASSWORDHASH_H
    17. #define JOOMLA15PASSWORDHASH_H
    18. //
    19. #include <stdlib.h>
    20. #include <time.h>
    21. #include <QString>
    22. #include <QStringList>
    23. #include <QByteArray>
    24. #include <QCryptographicHash>
    25. //
    26. class Joomla15PasswordHash
    27. {
    28. private:
    29.  
    30. public:
    31. Joomla15PasswordHash();
    32. bool check(QString passwd,QString dbEntry);
    33. QString create(QString passwd);
    34. QString md5(QString data);
    35. };
    36. #endif
    To copy to clipboard, switch view to plain text mode 


    File joomla15passwordhash.cpp
    Qt Code:
    1. /* Joomla15passwordhash Class 1.0
    2.  * Copyright
    3.  * Smart Neural Tech LTD
    4.  * www.smartneural.com
    5.  * rajab@smartneural.com
    6.  *
    7.  * Developer Name: Rajab Natshah
    8.  * rajab@natshah.com
    9.  *
    10.  * This Class helps you use username and passwords
    11.  * from the Joomla 1.5 database Cryptographic Hash using QT Library.
    12.  * And C++ Class.
    13.  *
    14.  */
    15.  
    16.  
    17.  
    18. #include "joomla15passwordhash.h"
    19. //
    20. Joomla15PasswordHash::Joomla15PasswordHash()
    21. {
    22.  
    23. }
    24. bool Joomla15PasswordHash::check(QString passwd,QString dbEntry)
    25. {
    26.  
    27. // new format as {HASH}:{SALT}
    28. QStringList aar = dbEntry.split(":");
    29. QString cryptpass = aar[0];
    30. QString salt = aar[1];
    31. bool result = (md5(passwd+salt) == cryptpass);
    32. return result ;
    33.  
    34. }
    35.  
    36. QString Joomla15PasswordHash::create(QString passwd)
    37. {
    38. QString salt;
    39. int _rnd;
    40. srand ( time(NULL) );
    41. for (int i=0;i<32;i++)
    42. {
    43. _rnd = rand()%36+1;
    44. salt.append(QString::number(_rnd,36));
    45. }
    46. return md5(passwd+salt)+":"+salt;
    47. }
    48.  
    49. QString Joomla15PasswordHash::md5(QString data) {
    50. QByteArray bdata;
    51. bdata.resize(data.length());
    52. int i;
    53. QByteArray hash;
    54.  
    55. bdata = data.toUtf8();
    56. for (i=0;i<data.length();i++)
    57. bdata[i]= bdata[i]&0xff;
    58.  
    59. hash = QCryptographicHash::hash(bdata, QCryptographicHash::Md5);
    60.  
    61.  
    62. for (i=0;i<hash.length();i++) {
    63. QString x = QString::number(hash[i]&0xff,16);
    64. if (x.length()<2) r.append("0");
    65. r.append(x);
    66. }
    67.  
    68. return r;
    69. }
    70. //
    To copy to clipboard, switch view to plain text mode 

    I hope you can use it in your projects.
    and any help I'm available.

    I have attached the files so you can use them directly in your Development under QT Library

    Best Regards
    Rajab Natshah
    Attached Files Attached Files
    Last edited by RajabNatshah; 6th October 2009 at 16:02.

  2. The following user says thank you to RajabNatshah for this useful post:

    kosasker (24th March 2011)

Similar Threads

  1. Extending two class "the same way"
    By caduel in forum General Programming
    Replies: 3
    Last Post: 22nd July 2009, 22:55
  2. class QHBoxLayout
    By csvivek in forum Installation and Deployment
    Replies: 2
    Last Post: 10th April 2008, 07:57
  3. Replies: 2
    Last Post: 4th May 2006, 19:17

Tags for this Thread

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.