How can I encrypt a string with AES 256 so it can be decrypted on a webserver in Java?
I need to know how to encrypt a string using AES 256 bit algorithm with specified key in 开发者_如何学GoiPhone, so that the encrypted string can be decrypted in Java.
The goal is to transfer that string securely from the iPhone to a webserver.
maybe you need to compile openssl, try this tuto http://www.x2on.de/2010/07/13/tutorial-iphone-app-with-compiled-openssl-1-0-0a-library/ or use the CCCryptor see this post, exist a lot of information about this topic.
Personally i used openssl to do a similar work.
Cheers!
I don't know enough about iPhone to answer the first part.
For the second part it should be easy enough to decrypt in Java provided everything is specified correctly. Using AES-256 is a good start. Explicitly specify CBC mode and PKCS7 padding. Use a random IV and, obviously, a secret key.
At the Java side make sure you use the same: AES-256 in CBC mode with PKCS7 padding. Use the same IV and the same key. The IV can be sent "in clear", many systems prepend it to the cyphertext. You will need a way to securely transfer the key to the destination.
Be sure you know when you are dealing with bytes and when you are dealing with text. You can convert bytes to text by using Base64. If you do use text then ensure that both sides use the same text encoding for the transferred files, UTF-8 for preference.
精彩评论