title: AES 256 in Blackberry
body: <p>How can I do AES 256 encryption in Blackberry...</p>
  
  <p>I am using for encryption : but not get data  <strong>AES256 standard</strong> : </p>
  
  <pre><code> private static byte[] encrypt( byte[] keyData, byte[] data ) throws CryptoException, IOException
      {
          // Create the AES key to use for encrypting the data.
          // This will create an AES key using as much of the keyData
          // as possible.
          AESKey key = new AESKey( keyData );
  
          // Now, we want to encrypt the data.
          // First, create the encryptor engine that we use for the actual
          // encrypting of the data.
          AESEncryptorEngine engine = new AESEncryptorEngine( key );
  
          // Since we cannot guarantee that the data will be of an equal block
          // length we want to use a padding engine (PKCS5 in this case).
          PKCS5FormatterEngine fengine = new PKCS5FormatterEngine( engine );
  
          // Create a BlockEncryptor to hide the engine details away.
          ByteArrayOutputStream output = new ByteArrayOutputStream();
          BlockEncryptor encryptor = new BlockEncryptor( fengine, output );
  
          // Now, all we need to do is write our data to the output stream.
          // But before doing so, let's calculate a hash on the data as well.
          // A digest provides a one way hash function to map a large amount
          // of data to a unique 20 byte value (in the case of SHA1).
          SHA1Digest digest = new SHA1Digest();
          digest.update( data );
          byte[] hash = digest.getDigest();
  
          // Now, write out all of the data and the hash to ensure that the
          // data was not modified in transit.
          encryptor.write( data );
          encryptor.write( hash );
          encryptor.close();
          output.close();
  
          // Now, the encrypted data is sitting in the ByteArrayOutputStream.
          // We simply want to retrieve it.
          return output.toByteArray();
      }
  </code></pre>