Note that there are some explanatory texts on larger screens.

plurals
  1. POCan any one help me out how to decrypt(AES128) the message in iOS which is encrypted in JAVA (AES Decryption 128)
    primarykey
    data
    text
    <p>Please find the below method which we are using.</p> <p>The key received from server in Hexa: 1EF5F2D644FBA8E4142778CD43D70BFA</p> <p>The encoded message received from server: /lGtPU2K29FZPNtrc9DKow==</p> <p>If we decrypt the above message it should be "hi"</p> <p>I am unable to decrypt it in iOS side. Can anyone help me out please.</p> <pre><code>- (NSData *)AES128DecryptWithKey:(NSString *)key { // 'key' should be 16 bytes for AES128, will be null-padded otherwise char keyPtr[kCCKeySizeAES128+1]; // room for terminator (unused) bzero(keyPtr, sizeof(keyPtr)); // fill with zeroes (for padding) // fetch key data [key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding]; NSUInteger dataLength = [self length]; //See the doc: For block ciphers, the output size will always be less than or //equal to the input size plus the size of one block. //That's why we need to add the size of one block here size_t bufferSize = dataLength + kCCBlockSizeAES128; void *buffer = malloc(bufferSize); size_t numBytesDecrypted = 0; CCCryptorStatus cryptStatus = CCCrypt(kCCDecrypt, kCCAlgorithmAES128, 0,keyPtr, kCCKeySizeAES128, NULL /* initialization vector (optional) */, [self bytes], dataLength, /* input */ buffer, bufferSize, /* output */ &amp;numBytesDecrypted); if (cryptStatus == kCCSuccess) { //the returned NSData takes ownership of the buffer and will free it on deallocation return [NSData dataWithBytesNoCopy:buffer length:numBytesDecrypted]; } free(buffer); //free the buffer; return nil; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload