title: How to AES-GCM for iOS and Android
body: <p>i want to create AES encrypt and decrypt GCM mode with authentication tag.
  This is my source code of iOS version:</p>
  
  <pre><code>CCCryptorStatus ccStatus = kCCSuccess;
  NSData *iv = [hexIV dataUsingEncoding:NSUTF8StringEncoding];
  NSData *symmetricKey = [hexIV dataUsingEncoding:NSUTF8StringEncoding];
  NSMutableData  *dataOut = [NSMutableData dataWithLength:self.length];
  NSMutableData  *tag = [NSMutableData dataWithLength:kCCBlockSizeAES128];
  size_t          tagLength = kCCBlockSizeAES128;
  
  ccStatus = CCCryptorGCM(kCCEncrypt,
                          kCCAlgorithmAES,
                          symmetricKey.bytes,
                          kCCKeySizeAES256,
                          iv.bytes,
                          iv.length,
                          aad.bytes,
                          aad.length,
                          self.bytes,
                          self.length,
                          dataOut.mutableBytes,
                          tag.bytes,
                          &amp;tagLength);
  
  if (ccStatus == kCCSuccess) {
      return [NSDictionary dictionaryWithObjectsAndKeys:dataOut,@"cyphertext",tag,@"tag",iv,@"iv",nil];
  } else {
      return nil;
  }
  </code></pre>
  
  <p>I want to change this code to Android version, below Android's source code:</p>
  
  <pre><code>byte[] aKey = hexStringToByteArray(hexKey);
  byte[] aIV = hexStringToByteArray(hexIV);
  Key key = new SecretKeySpec(aKey, "AES");
  Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
  cipher.init(Cipher.ENCRYPT_MODE, key, new GCMParameterSpec(16 * Byte.SIZE, aIV));
  cipher.updateAAD(aad);
  byte[] encrypted = cipher.doFinal(aKey);
  </code></pre>
  
  <p>How to add authentication tag into my source code?</p>