3

Hi this a QR Encoder project found at github by myang, https://github.com/myang-git/QR-Code-Encoder-for-Objective-C i want to use the encode and decode functionality provided here, am able to successsfully create a QR code with encrypted string but am not able to decode it...

How do i decode the string returned after scanning the QR code...

the method provided for decrypting takes nsdata and passphase parameter i tried converting the scanned string to nsdata and then passing it as parameter to this function , but its not working...

how do i decode the string??

this is what i do to encode then string ..

     DataMatrix* qrMatrix = [QREncoder encodeWithECLevel:QR_ECLEVEL_AUTO version:QR_VERSION_AUTO string:aVeryLongURL AESPassphrase:@"xyz"];

UIImage* qrcodeImage = [QREncoder renderDataMatrix:qrMatrix imageDimension:qrcodeImageDimension];

and this is what i tried to decode the string returned after scanning....

NSString *strReturedAfterscanning=@"ñ?³éMX¹Ç7T?îéz°z ";
NSData* data=[strReturedAfterscanning dataUsingEncoding:NSUTF8StringEncoding];
NSString *str1=[QREncoder AESDecryptString:data withPassphrase:@"xyz"];

this is not working??

H Bastan
  • 259
  • 1
  • 2
  • 11
  • How did you generate that string literal? It's pretty suspect: NSStrings are UTF-16 and encrypted data is usually raw bytes. The two aren't, in general, compatible. – smparkes Jun 01 '12 at 14:48
  • @smparkesyes you are right , it returns raw bytes that are converted to nsdata and that nsdata is used to generate the QR image ,now when this QR image is scanned using zbar i get the following string @"ñ?³éMX¹Ç7T?îéz°z " ...so how do i get the correct data so that i can decode it ?? – H Bastan Jun 02 '12 at 06:20
  • I don't know the ZBar API but you need to get access to the raw bytes, not as coerced into an NSString. Alternatively, you could base64 encode the encrypted data, with the disadvantage that that will take 33% more bits. – smparkes Jun 02 '12 at 14:38
  • What code exactly do you use to decode the qrcode ? – edi9999 Jul 16 '13 at 10:52

0 Answers0