AES ECB iOS Encrypt
<p>I try to encrypt some string using AES algorithm with ECB option.</p>

<pre><code>size_t bufferSize = dataLength + kCCBlockSizeAES128;
void *buffer = malloc(bufferSize);

size_t numBytesEncrypted = 0;
CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt, kCCAlgorithmAES128, kCCOptionECBMode,
                                      encryptionKey, kCCKeySizeAES128,
                                      NULL /* initialization vector (optional) */,
                                      [self bytes], dataLength, /* input */
                                      buffer, bufferSize, /* output */
                                      &amp;numBytesEncrypted);
if (cryptStatus == kCCSuccess) {
    return [NSData dataWithBytesNoCopy:buffer length:numBytesEncrypted];
}
</code></pre>

<p>But func returns kCCAlignmentError (-4303)</p>

<p>Then I try to align data:</p>

<pre><code>unsigned long diff = kCCKeySizeAES128 - (dataLength % kCCKeySizeAES128);
unsigned long newSize = 0;

if (diff &gt; 0) {
    newSize = dataLength + diff;
}

char dataPtr[newSize];
memcpy(dataPtr, [self bytes], [self length]);
for(int i = 0; i &lt; diff; i++) {
    dataPtr[i + dataLength] = 0x20;
}

size_t numBytesEncrypted = 0;
CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt, kCCAlgorithmAES128, kCCOptionECBMode,
                                      encryptionKey, kCCKeySizeAES128,
                                      NULL /* initialization vector (optional) */,
                                      dataPtr, sizeof(dataPtr), /* input */
                                      buffer, bufferSize, /* output */
                                      &amp;numBytesEncrypted);
</code></pre>

<p>input string </p>

<pre><code>"test_string,test2"
</code></pre>

<p>result is </p>

<pre><code>jxtFOhYpgBVieM90zx9oDanqBkcsVAvRRJsM4GL3cio=
</code></pre>

<p>On Android result is </p>

<pre><code>jxtFOhYpgBVieM90zx9oDUfV7v43WFv7F5bzErfxrL8=
</code></pre>

<p>What did I wrong?</p>