Discussion Board

Results 1 to 13 of 13
  1. #1
    Regular Contributor abdullah.jobayer's Avatar
    Join Date
    Feb 2009
    Posts
    51
    Hi

    I have encrypted string in this way.string1 is encrypted.now i want to decrypt this string.How can i.Is there any one help?

    QByteArray string="Nokia";
    QCryptographicHash *hash=new QCryptographicHash(QCryptographicHash::Md4);
    hash->addData(string);
    QByteArray string1=hash->result();

    With Regards
    jobayer

  2. #2
    Nokia Developer Moderator isalento's Avatar
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    832
    Hi,

    Please correct me if I am wrong, but that class seems to be only for computing "digital fingerprints". For example, you can see if someone has tampered with the data by comparing checksums that are calculated after and before sending the data.

    http://en.wikipedia.org/wiki/Cryptog..._hash_function
    http://wiki.qtcentre.org/index.php?title=Cryptography

    Br,
    Ilkka

  3. #3
    Nokia Developer Champion james1980's Avatar
    Join Date
    Sep 2007
    Location
    Bhavnagar
    Posts
    916
    Hi,

    I think there is no such a function for decryption of the encrypted string.
    Jajal Mehul

  4. #4
    Nokia Developer Moderator petrib's Avatar
    Join Date
    Mar 2003
    Posts
    9,415
    Quote Originally Posted by james1980 View Post
    I think there is no such a function for decryption of the encrypted string.
    It depends... Typically encryption algorithms also have a corresponding decryption algorithm (if you can't decrypt data, then in most cases encrypting it in the first place is pretty pointless; you might just as well delete the data).

    However, as stated in the first reply, a hash function is not encrypting anything; it is using the original data to calculate a fingeprint of the data, but the fingeprint does not contain the actual original data at all.

  5. #5
    Regular Contributor abdullah.jobayer's Avatar
    Join Date
    Feb 2009
    Posts
    51
    Thanks to reply

    Actually how i can encrypt & decrypt string in QT.

    Previously i have done encryption & decryption string by DES algo.

    If i so in this is it possible.How i can pls help any one

    Jobayer.

  6. #6
    Registered User kamalakshan's Avatar
    Join Date
    Jun 2007
    Location
    Mumbai, India
    Posts
    1,998
    AFAIK Qt doesn't have built-in support for encryption but you should be able to use any encryption library.

  7. #7
    Regular Contributor abdullah.jobayer's Avatar
    Join Date
    Feb 2009
    Posts
    51
    Thanks to reply.

    I am trying by using library.

    With Regards
    Jobayer

  8. #8
    Regular Contributor rahul.shalik.makode's Avatar
    Join Date
    Oct 2008
    Posts
    135
    hi,

    i am using cryptography encrypt function

    CRSAPKCS1v15Encrypto

    iEncryptor.EncryptL( const TDesC8 &aInput,TDes8 &aOutput);

    for this function i am passing

    TBuf8<2> cipher;
    /TBuf8<2> text;

    iEncryptor.EncryptL(__L("Hello"),cipher);

    but it shows errors

    plz any body told me what is mistake while passing args

  9. #9
    Registered User kamalakshan's Avatar
    Join Date
    Jun 2007
    Location
    Mumbai, India
    Posts
    1,998
    Quote Originally Posted by rahul.shalik.makode View Post
    hi,

    i am using cryptography encrypt function

    CRSAPKCS1v15Encrypto

    iEncryptor.EncryptL( const TDesC8 &aInput,TDes8 &aOutput);

    for this function i am passing

    TBuf8<2> cipher;
    /TBuf8<2> text;

    iEncryptor.EncryptL(__L("Hello"),cipher);

    but it shows errors

    plz any body told me what is mistake while passing args


    what is the error you are getting. whether it is runtime or compile time error?

  10. #10
    Regular Contributor rahul.shalik.makode's Avatar
    Join Date
    Oct 2008
    Posts
    135
    hi,

    i have implemented class using cryptography api,

    in that class i have ccreated instance of

    iRSAKeyPair = CRSAKeyPair::NewL(aModulusBits, EStandardCRT) ;

    const CRSAPublicKey &iRSAPublicKey =iRSAKeyPair->PublicKey() ;

    iEncryptor = CRSAPKCS1v15Encryptor::NewL(iRSAPublicKey);

    in constructL() of my class

    and also called encrypt method

    but while creating instance of my class in ui file

    it show error

    ..............error...........

    you r opening large file turning on scalability mode might help improve editor performance .plz see scalability mode page under preference->c/c++ editor

    ...........error.........

    i channged scalabilty mode on on for 5000 lines

    i have include cryptography.h and lib file

    i think b'coz of that size of class goes increasing

    and while debuging...it shows error

    //...........h file


    #ifndef RSAALGO_H_
    #define RSAALGO_H_

    #include <cryptoasymmetric.h>
    #include <signed.h>
    #include <cryptopanic.h>
    //#include <x509keys.h>

    #include <e32base.h>
    #include <e32std.h>
    #include <cryptobasic.h>
    #include <cryptoasymmetric.h>
    #include <hash.h>
    #include <signed.h>

    class CRSAAlgo
    {
    public:

    CRSAAlgo();
    virtual ~CRSAAlgo();

    public:
    static CRSAAlgo* NewL();
    static CRSAAlgo* NewLC();

    TBool EncryptL(const TDesC8 &aInput, TDes8 &aOutput);

    //TBuf16<2> text,cipher;

    //void stringToDescriptor(const char* aString, TDes& aDescriptor);

    private:

    void ConstructL();

    protected:

    //CRSAPublicKey *iPKey;

    //CRSAPKCS1v15Encryptor *iEncryptor;

    //CRSAKeyPair *iRSAKeyPair ;

    //TUint aModulusBits;


    protected:

    CRSAKeyPair *iRSAKeyPair ;

    CRSAPKCS1v15Encryptor *iEncryptor;

    //CRSAPKCS1v15Decryptor iDecrypter;


    //CRSAPublicKey iRSAPublicKey ;



    //CRSAPrivateKey iRSAPrivateKey ;


    //static RInteger iN;
    //static RInteger iE;
    };

    ..........................

    .............cpp file ...............
    /*
    * RSAAlgo.cpp
    *
    * Created on: May 21, 2009
    * Author: rahul.makode
    */


    /*
    * RSAEncryption.cpp
    *
    * Created on: May 19, 2009
    * Author: rahul.makode
    */

    #include "RSAAlgo.h"
    //#include <cryptopanic.h>

    #include <cryptoasymmetric.h>

    #include <aknnotewrappers.h>




    CRSAAlgo::CRSAAlgo()
    {

    iRSAKeyPair=NULL;



    //iRSAPublicKey = NULL;
    //iRSAPrivateKey = NULL;

    //iPKey = NULL;
    //iEncryptor = NULL;
    //iRSAKeyPair=NULL;

    //aModulusBits=0;

    }
    CRSAAlgo::~CRSAAlgo()
    {
    /*iN.Close();
    iE.Close();
    if(iEncryptor)
    {
    delete iEncryptor;
    iEncryptor = NULL;
    }
    if(iPKey)
    {
    delete iPKey;
    iPKey = NULL;
    }*/
    /* if(iPublic)
    {
    delete iPublic;
    iPublic = NULL;
    }
    if(iPrivate)
    {
    delete iPrivate;
    iPrivate = NULL;
    }*/
    }
    CRSAAlgo* CRSAAlgo::NewL()
    {
    CRSAAlgo *self = CRSAAlgo::NewLC();
    CleanupStack::Pop(self);
    return self;

    }


    CRSAAlgo* CRSAAlgo::NewLC( )
    {
    CRSAAlgo *self = new (ELeave) CRSAAlgo;
    CleanupStack::PushL(self);



    //iN = RInteger::NewL(aN);
    //iE = RInteger::NewL(aE);



    self->ConstructL();
    return self;
    }
    void CRSAAlgo::ConstructL()
    {

    TBuf<100> mess;

    TUint aModulusBits;

    aModulusBits=128;


    //iRSAKeyPair=CRSAKeyPair::NewL(aModulusBits);

    iRSAKeyPair = CRSAKeyPair::NewL(aModulusBits, EStandardCRT) ;

    const CRSAPublicKey &iRSAPublicKey =iRSAKeyPair->PublicKey() ;

    iEncryptor = CRSAPKCS1v15Encryptor::NewL(iRSAPublicKey);



    mess.Append(_L("public key:"));

    //TInt num(-6);
    //TBuf<8> des;
    //take care of number of digits. if it exceed defined in TBuf<>, 8 here, it gives panic.
    //des.Num(iRSAPublicKey);

    //mess.Copy(des);


    //TBuf<32> buffer; // Make it large enough for str

    //stringToDescriptor(str, text);

    TBuf8<10> text;

    TBuf8<10> cipher;

    text.Copy(_L("Hello"));

    /* TBuf8<64> plaintext;

    plaintext.Append(_L("Hello"));


    HBufC8* plainText = HBufC8::NewLC(64);
    TPtr8 plainTextPtr = plainText->Des();*/

    //iEncryptor.
    EncryptL(text,cipher);

    mess.Append(_L("encrypted string"));

    mess.Copy(cipher);


    // iEncryptor.EncryptL(plainTextPtr,cipher);




    //mess.Append(cipher);

    //TBuf8<64> plaintext;

    //mess.AppendNum(iRSAPublicKey);


    //mess.AppendNum(TInt64(iRSAPublicKey ));

    //mess.AppendNum(iRSAPublicKey);

    const CRSAPrivateKey &iRSAPrivateKey =iRSAKeyPair->PrivateKey();

    //iDecrypter = CRSAPKCS1v15Decryptor::NewL(iRSAPrivateKey);

    TInt err;

    CRSAPKCS1v15Decryptor * decryptor;

    TRAP(err,decryptor= CRSAPKCS1v15Decryptor::NewLC(iRSAPrivateKey));




    mess.Append(_L("private key:"));


    //mess.Copy(iRSAKeyPair);


    CAknInformationNote* note = new (ELeave) CAknInformationNote;

    // note->SetTimeout( CAknNoteDialog::ELongTimeout );

    // TBuf<0x100> buf;

    // buf.Format( _L("HandleGetByAttributeL( %i )"), aStatus );

    note->ExecuteLD( mess);




    //iRSAPublicKey = i
    //iRSAPrivateKey = iRSAKeyPair->PrivateKey();



    /*iPKey = CRSAPublicKey::NewL(iN,iE);
    *
    *

    if(iPKey)
    {
    iEncryptor = CRSAPKCS1v15Encryptor::NewL(*iPKey);
    }
    */
    /*iPrivate=iRSAKeyPair.PrivateKey();
    iPublic=iRSAKeyPair.PublicKey();

    console->Printf(iPrivate);

    console->Printf(iPublic);*/


    //iRSAKeyPair.PrivateKey();
    //iRSAKeyPair.iPrivate=iPrivate=iRSAKeyPair.PrivateKey();


    //iPrivate=
    //iRSAKeyPair.PrivateKey();


    //iPublic=iRSAKeyPair.PublicKey();



    }

    TBool CRSAAlgo::EncryptL(const TDesC8 &aInput,TDes8 &aOutput)
    {
    if(iEncryptor)
    {
    TInt len = iEncryptor->MaxInputLength();
    if(aInput.Length() > len)
    return false;

    TRAPD(retval,iEncryptor->EncryptL(aInput,aOutput));
    if(retval != KErrNone)
    {
    switch(retval)
    {
    case ECryptoPanicOutputDescriptorOverflow:
    {
    retval = 0;
    }
    break;
    case ECryptoPanicPadInputTooLarge :
    {
    retval = 1;
    }
    break;
    case ECryptoPanicInputTooLarge :
    {
    retval = 2;
    }
    break;
    default:
    retval = 3;
    }
    return false;
    }

    return true;
    }

    return false;
    }
    /*

    void CRSAAlgo:ecryptL(const TDesC8 &aInput, TDes8 &aOutput)
    {

    }
    */

    /*
    void CRSAAlgo::stringToDescriptor(const char* aString, TDes& aDescriptor)
    {
    TPtrC8 ptr(reinterpret_cast<const TUint8*>(aString));
    aDescriptor.Copy(ptr);
    }*/


    .........................

    i am using cryptography api plz sugest me how to used cryptography api in our class

  11. #11
    Registered User kamalakshan's Avatar
    Join Date
    Jun 2007
    Location
    Mumbai, India
    Posts
    1,998
    What is the error you are getting. Also there is an example in wiki I think related to cryptography api.

  12. #12
    Regular Contributor rahul.shalik.makode's Avatar
    Join Date
    Oct 2008
    Posts
    135
    my application is crashing on emulator

    1)no souce code (strong_cryptography.dll) not found

    i have added the .h and lib for cryptography api

    2)also if there is any prob for passing values to encyptl()

    i dont know exact prob

  13. #13
    Registered User kamalakshan's Avatar
    Join Date
    Jun 2007
    Location
    Mumbai, India
    Posts
    1,998
    When crashing do you get any panic code. Please check this.

Similar Threads

  1. C++ 學習程序2
    By hanwen813 in forum [Archived] Other Programming Discussion 关于其他编程技术的讨论
    Replies: 32
    Last Post: 2009-04-02, 09:10
  2. Send string data from symbian to .net
    By ahlmans in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2008-01-16, 13:40
  3. How to use Gauge/Process Bar when using HttpConnection?
    By Tanya in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2006-12-28, 07:59
  4. Personal
    By JSmith77 in forum PersonalJava
    Replies: 4
    Last Post: 2003-07-30, 12:52
  5. D211 new linux driver 1.04 not working !!
    By franz_meyer in forum Multimodecards
    Replies: 1
    Last Post: 2002-12-12, 08:31

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved