Now I want to encrypt or decrypt some data in object-c use DES algorithm ,can somebody give me some suggestion?
Asked
Active
Viewed 3,545 times
0
-
Do you have the option of encrypting the data with a more secure algorithm like AES? DES has been shown to be insecure. http://en.wikipedia.org/wiki/Data_Encryption_Standard. Are you planning to encrypt the data as you send it or are you planning to encrypt and store the data on the phone? – Holtorf Jan 05 '11 at 07:21
2 Answers
1
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.
- Add the Security.framework to your project.
- Import the "CommonCrypto/CommonCryptor.h" file. This contains all the interfaces for symmetric encryption.
- 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.
- 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.

Karan Rath
- 134
- 2
-
1
-
details... details please! I have a very old ntlm authentication code that uses DES ebb - but using openSSL APIs. Now openSSL was finally removed from MacOS (as well as iOS long time ago) So I must convert the code to use the commonCrypto APIs - but I find it hard, since I'm not familiar with encryption parameters, algorithms etc... so a small sample will be GREATLY appreciated. – Motti Shneor Apr 23 '18 at 12:15
1
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.

Community
- 1
- 1

Guruniverse
- 196
- 2
- 6