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

Now I want to encrypt or decrypt some data in an object-oriented DES algorithm, can someone give me some suggestion?

0
source share
2 answers

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

Second point: No matter what you decide, this is what you need to do.

  • Add the Security.framework project to the project.
  • Import the file "CommonCrypto / CommonCryptor.h". It contains all interfaces for symmetric encryption.
  • Using the methods of this class, you can define your encryption algorithm (AES, DES, etc.), the key size, the add-on you want to use, etc.
  • If necessary, you should use a one-time API for encryption / decryption (CCCrypt ()) or more complex parameters.

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

+1
source

Sample code can be found in How to encrypt NSString in Objective-C with DES in ECB mode?

As described in this section, you need to keep in mind that DES uses 56-bit (7 bytes) and 64-bit (8 bytes) blocks.

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

0
source

All Articles