Results 1 to 1 of 1

Thread: [SOLVED] About QCA and fromPemFile function

  1. #1
    Join Date
    Jan 2011
    Location
    Gordion
    Posts
    52
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: [SOLVED] About QCA and fromPemFile function

    When reading
    Qt Code:
    1. QCA::ConvertResult conversionResult;
    2. QCA::PublicKey pubkey2 = QCA::PublicKey::fromPEMFile("publickey.pem", &conversionResult);
    To copy to clipboard, switch view to plain text mode 
    ConvertResult must have.

    Edit.. Oh man.. Complete code is here.

    Qt Code:
    1. QCA::ConvertResult conversionResult;
    2. QCA::PublicKey pubkey2 = QCA::PublicKey::fromPEMFile("publickey.pem", &conversionResult);
    3. if (! QCA::ConvertGood == conversionResult)
    4. {
    5. std::cout << "Public key read failed" << std::endl;
    6. }
    7. if (pubkey2.isNull())
    8. {
    9. qDebug() << "error";
    10. return;
    11. }
    12. if (!pubkey2.canEncrypt())
    13. {
    14. qDebug() << "Error: this kind of key cannot encrypt" << endl;
    15. return;
    16. }
    17. // lets try to encrypt again
    18.  
    19. QCA::SecureArray result2 = pubkey2.encrypt("argi",QCA::EME_PKCS1v15);
    20.  
    21. if (result2.isEmpty())
    22. {
    23. qDebug()<< "encrypting error";
    24. return;
    25. }
    26.  
    27. QString str2 = QCA::arrayToHex(result2.toByteArray());
    28. ui->textEdit_2->setText(str2);
    To copy to clipboard, switch view to plain text mode 
    Last edited by kosasker; 25th May 2011 at 09:52. Reason: solved

Similar Threads

  1. Replies: 7
    Last Post: 9th December 2010, 22:26
  2. Replies: 2
    Last Post: 13th September 2010, 20:03
  3. Replies: 3
    Last Post: 25th May 2010, 09:46
  4. Replies: 0
    Last Post: 10th March 2010, 08:13
  5. Zip function for Qt4
    By devilj in forum Newbie
    Replies: 7
    Last Post: 15th July 2007, 14:37

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.