开发者

how to use DES algorithm to encrypt or decrypt some data in object-c?

Now I want to encrypt or decrypt some data in object-c use DES algo开发者_如何学JAVArithm ,can somebody give me some suggestion?


First point. AES has replaced DES as the de-facto encrpytion standard, at least for the banking industry.

Second Point: Irrespective of what algo you decide on, this is what you have to do.

  1. Add the Security.framework to your project.
  2. Import the "CommonCrypto/CommonCryptor.h" file. This contains all the interfaces for symmetric encryption.
  3. Using the methods in this class, you can define your encryption algo (AES, DES, etc.), the key size, padding that you want to use, etc.
  4. You have to option of a one-shot API for encryption/decryption (CCCrypt()) or more advanced options if needed.

Hope this helps. Let me know if you need any particular information.


A code sample can be found in How to encrypt an NSString in Objective C with DES in ECB-Mode?

As the referring topic describes, you will have to keep in mind that DES uses a 56-bit (7 bytes) key and 64-bit (8 bytes) blocks.

Although DES is symmetric you will have to decrypt data by providing the kCCDecrypt option to the CCCrypt function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜