Closed manishmundra3 closed 9 years ago
What is the expected Decrypted data ? This looks like duplicate of this issue - https://github.com/Pakhee/Cross-platform-AES-encryption/issues/10#issuecomment-91379847
Make sure your IV is 16 characters and consider randomizing your IV.
Hello Navneet, My encrypted string is : 97Dfy+pLJFA+RqYR8nX8YFr6JuVC5UUOQceV93kN4aUU+qUvjMa+2Z1iifcrG/U6
Actual string is :
This is test Encryption String One
string iv = "VFSGlobalApp";
string key = CryptLib.getHashSha256("VFSGlobalApp", 31); //32 bytes = 256 bits
Then i decrypt this encrypted text then i get nothing.
Thanks & Regards, Manish Mundra
On Tue, Jun 16, 2015 at 11:40 PM, Navneet Kumar notifications@github.com wrote:
What is the expected Decrypted data ? This looks like duplicate of this issue - #10 (comment) https://github.com/Pakhee/Cross-platform-AES-encryption/issues/10#issuecomment-91379847
Make sure your IV is 16 characters and consider randomizing your IV.
— Reply to this email directly or view it on GitHub https://github.com/Pakhee/Cross-platform-AES-encryption/issues/15#issuecomment-112517418 .
Did you read my previous comment and implement changes accordingly ?
Yes, i did but response is not according my encrypted string.
NSString *iv = @"GlobalApp";
NSString *key = [[CryptLib alloc]sha256:@"GlobalApp"
length:32];//getHashSha256(@"GlobalApp", 31); //32 bytes
NSString * secret = @"This is test Encryption String Two";
r+jolqNoBBq/XCV9rrXzQwmFt8jCD/AHYdzIG/ECVUAVFsAIaYOQy+xzYrq8/Ayx
NSData * encryptedData = [[CryptLib alloc] encrypt:[secret
dataUsingEncoding:NSUTF8StringEncoding] key:key iv:iv];
NSString *encryptedText = [encryptedData
base64EncodingWithLineLength:0];
NSData * decryptedData = [[CryptLib alloc] decrypt:[encryptedText
dataUsingEncoding:NSUTF8StringEncoding] key:key iv:iv];
NSString * decryptedText = [decryptedData
base64EncodingWithLineLength:0];
Output :
Mk8OOh3yQ3KyddqzQ/xjReakOoUMcXBGXmZT0ZzUNrGNgRF/rwFkGZBup3j0k5LT5Cw3x+9201F89ri3l610qg==
Thanks & Regards, Manish Mundra
On Wed, Jun 17, 2015 at 9:56 AM, Navneet Kumar notifications@github.com wrote:
Did you read my previous comment and implement changes accordingly ?
— Reply to this email directly or view it on GitHub https://github.com/Pakhee/Cross-platform-AES-encryption/issues/15#issuecomment-112649328 .
What is your IV ? In your code you have used - NSString *iv = @"GlobalApp"; This has just 9 characters while I had mentioned that you'll need at least 16 characters.
// My testing string is "This is test Encryption String Two"
NSString str=[[NSBundle mainBundle] pathForResource:@"data" ofType:@"rtf"]; NSData data = [NSData dataWithContentsOfFile:str];
NSString iv = @"VFSGlobalApp"; NSString key = [[CryptLib alloc]sha256:@"VFSGlobalApp" length:31];//getHashSha256(@"VFSGlobalApp", 31); //32 bytes
NSData dataencrypt = [[CryptLib alloc]encrypt:data key:key iv:iv]; NSData base64 = [dataencrypt base64EncodedDataWithOptions:0]; NSString *sBase64 = [[NSString alloc] initWithData:base64 encoding:NSUTF8StringEncoding]; NSLog(@"Base64 String: %@",sBase64);
NSData datadecrypt = [[CryptLib alloc]decrypt:dataencrypt key:key iv:iv]; NSString sDecrypt = [[NSString alloc] initWithData:datadecrypt encoding:NSUTF8StringEncoding]; NSLog(@"Decrypted Data: %@",sDecrypt);
Decrypted Data: {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570 {\fonttbl\f0\fmodern\fcharset0 CourierNewPSMT;\f1\froman\fcharset0 TimesNewRomanPSMT;} {\colortbl;\red255\green255\blue255;\red163\green21\blue21;} \margl1440\margr1440\vieww9000\viewh8400\viewkind0 \deftab720 \pard\pardeftab720
\f0\fs20 \cf2 This is test Encryption String Two \f1\fs24 \cf0 \ }
Please help me out.