Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to decrypt a encrypted data?

how to decrypt a encrypted data?

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 4 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ManiRonM Offline
    ManiRonM Offline
    ManiRon
    wrote on last edited by
    #1

    I am trying to encrypt a data using the following code

    QCryptographicHash::hash(ui->LE_Pwd->text().toLatin1().toHex(), QCryptographicHash::Sha256).toHex()

    is there a way to decrypt the data ?

    aha_1980A JonBJ 3 Replies Last reply
    0
    • ManiRonM ManiRon

      I am trying to encrypt a data using the following code

      QCryptographicHash::hash(ui->LE_Pwd->text().toLatin1().toHex(), QCryptographicHash::Sha256).toHex()

      is there a way to decrypt the data ?

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @ManiRon: No

      Qt has to stay free or it will die.

      1 Reply Last reply
      4
      • ManiRonM ManiRon

        I am trying to encrypt a data using the following code

        QCryptographicHash::hash(ui->LE_Pwd->text().toLatin1().toHex(), QCryptographicHash::Sha256).toHex()

        is there a way to decrypt the data ?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @ManiRon
        As @aha_1980 says, there is deliberately no way to decrypt from QCryptographicHash::hash. It's an "asymmetric encryption".

        Is that what you want (i.e. "unbreakable"), or do you want to be able to decrypt? If the latter, you must pick some other "encryption/obfuscation" algorithm.

        ManiRonM 1 Reply Last reply
        3
        • JonBJ JonB

          @ManiRon
          As @aha_1980 says, there is deliberately no way to decrypt from QCryptographicHash::hash. It's an "asymmetric encryption".

          Is that what you want (i.e. "unbreakable"), or do you want to be able to decrypt? If the latter, you must pick some other "encryption/obfuscation" algorithm.

          ManiRonM Offline
          ManiRonM Offline
          ManiRon
          wrote on last edited by
          #4

          @JonB i need to decrypt the data as i want to display the user name so kindly provide any way

          JonBJ 1 Reply Last reply
          0
          • ManiRonM ManiRon

            @JonB i need to decrypt the data as i want to display the user name so kindly provide any way

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #5

            @ManiRon
            Well, say https://wiki.qt.io/Simple_encryption_with_SimpleCrypt gives source code, though there's quite a bit of code. Or there's https://stackoverflow.com/questions/21885140/aes-256-encryption-in-c-and-qt-5. Google for qt symmetric encryption or c++ symmetric encryption. Or, if you don't really want "encryption" but only "obfuscation", and you want to be as quick & lazy as possible, xor encryption c++. Depends what you want to achieve.

            1 Reply Last reply
            2
            • VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by
              #6

              You need an external library to encrypt/decrypt. You can use Crypto++ or libcrypto from OpenSSL

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              1 Reply Last reply
              2
              • ManiRonM ManiRon

                I am trying to encrypt a data using the following code

                QCryptographicHash::hash(ui->LE_Pwd->text().toLatin1().toHex(), QCryptographicHash::Sha256).toHex()

                is there a way to decrypt the data ?

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #7

                @ManiRon
                BTW, I note that what you want to encrypt seems to be a password. Often people assume they need to be able to later decrypt a password in order to validate it, but that is not the case. It depends on how you need to use the password:

                • If you do need to decrypt the password, so that for example you can send it on as the original clear-text to somewhere else, then it is true you will need to be able to decrypt.

                • However, if you only need to validate it against something a user has just typed in to make it sure they have the right the password, you do not need to decrypt. In this common case, all you need to do is store the correct password encrypted via a deterministic algorithm, and then when the user enters a password for validation you encrypt that proposed password using the same algorithm and then just compare that encryption against the one stored for equality. This is how passwords are typically stored in, say, a "provide your password to logon" --- there is no need/ability for a program to be able to decrypt back to the original password (which would be a security issue), it only needs to know whether the proposed password matches the stored one or not.

                ManiRonM 1 Reply Last reply
                4
                • JonBJ JonB

                  @ManiRon
                  BTW, I note that what you want to encrypt seems to be a password. Often people assume they need to be able to later decrypt a password in order to validate it, but that is not the case. It depends on how you need to use the password:

                  • If you do need to decrypt the password, so that for example you can send it on as the original clear-text to somewhere else, then it is true you will need to be able to decrypt.

                  • However, if you only need to validate it against something a user has just typed in to make it sure they have the right the password, you do not need to decrypt. In this common case, all you need to do is store the correct password encrypted via a deterministic algorithm, and then when the user enters a password for validation you encrypt that proposed password using the same algorithm and then just compare that encryption against the one stored for equality. This is how passwords are typically stored in, say, a "provide your password to logon" --- there is no need/ability for a program to be able to decrypt back to the original password (which would be a security issue), it only needs to know whether the proposed password matches the stored one or not.

                  ManiRonM Offline
                  ManiRonM Offline
                  ManiRon
                  wrote on last edited by
                  #8

                  @JonB No Sir i want to encrypt both password and user name

                  JonBJ VRoninV 2 Replies Last reply
                  0
                  • ManiRonM ManiRon

                    @JonB No Sir i want to encrypt both password and user name

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #9

                    @ManiRon
                    Makes no difference, above choice of algorithms applies equally if you have one or two strings to encrypt, still depends what you want to encrypt/decrypt for....

                    1 Reply Last reply
                    0
                    • ManiRonM ManiRon

                      @JonB No Sir i want to encrypt both password and user name

                      VRoninV Offline
                      VRoninV Offline
                      VRonin
                      wrote on last edited by
                      #10

                      @ManiRon said in how to decrypt a encrypted data?:

                      want to encrypt both password

                      Very easy to understand yet informative: https://www.youtube.com/watch?v=8ZtInClXe1Q

                      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                      ~Napoleon Bonaparte

                      On a crusade to banish setIndexWidget() from the holy land of Qt

                      1 Reply Last reply
                      2

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved