Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 92
Registered: ‎08-01-2013
My Device: Z10, Q5, Q10

aes algorith for large strings

Hi all,

 

I get a string from the server which is encrypted with AES128 and then hex encoded.

this string i need to decode at my side.

 

the string is not decoded properly. the output is not visible.

i reffered this for the process : http://chanduthedev.blogspot.in/2013/06/bb10-cryptography-sample-applicationaes.html

but this implementation does not support strings more than 16 in length.

so i fixed it this way :

 

QString Hash::encryptAes(QString input, QString key)
{
createAESKey(key) ;

qDebug() << "created aes key" ;
QString cipher ;
if(input.size() > 16)
{
for(int i = 0 ; i<input.size() ; i=i+16)
{
QString chars16 = input.mid(i, i+16) ;
qDebug() << "chars16 :: " <<chars16 ;
QString halfEncrypted = AESEncrypt(chars16) ;
cipher.append(halfEncrypted) ;
}
}
else
{
cipher = AESEncrypt(input);
}
return cipher ;
}

 

and decrypted as :

 

QString Hash::decryptAes(QString input, QString key)
{
QString pt ;
if(input.size() > 32)
{
for(int i = 0 ; i<input.size() ; i=i+32)
{
QString chars16 = input.mid(i, i+32) ;
qDebug() << "chars16 :: " <<chars16 ;
QString halfEncrypted = AESDecrypt(chars16) ;
qDebug() << "half decrypted :: " <<halfEncrypted ;

pt.append(halfEncrypted) ;
}
}
else
{
pt = AESDecrypt(input) ;
}

qDebug()<<"pt is "<<pt ;

return pt ;
}

 

the encryption at server (in java) is done in one go, so is the decryption chunk by chunk the problem??

if why please point me some implemention of aes 128 that does it one go.

Help!

 

Regards.

BlackBerry Development Advisor
Posts: 143
Registered: ‎03-08-2012
My Device: Z10

Re: aes algorith for large strings

Have you looked at the AESCrypto sample in our Cascades-Cumminty-Samples repo on GitHub?