Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • There are a few problems here. 1. The key length is incorrect. 2. The output is not being resized to numBytesEncrypted. 3. A UTF-8 String can not be created fom arbitrary data, that is not all data can form a UTF-8 string. Commented Sep 10, 2014 at 1:00
  • From a security standpoint t, and the assumption security is the desired result, using a String as a key is also a poor idea, if a String is used it should be used to derive a key with PBKFD2. Lastly: Do not use ECB mode, it is insecure, see ECB mode, scroll down to the Penguin. Instead use CBC mode with a random IV, just prefix the encrypted data with the IV for use in decryption, it does not need to not secret. Commented Jan 14, 2017 at 12:16
  • UInt32(cryptStatus) will crash if there is an error Commented Sep 21, 2020 at 11:17