encrypt a string using Des64 and Des192 encryption algorithm in iPhone sdk?
I want to encrypt a string using des64 and des192 in iPhone . I ha开发者_运维知识库ve searched the internet and found some code but the thing is I am not that aware of cryptography . I heard that in iPhone we can make use of security framework which has got cryptography functions. But they are totally c based and really hard to understand .
Can anybody please direct me to some helpful resource or explain the code which is used to encrypt in iPhone ???
Thanks in advance !!
Bharat
Sorry, Crypto isn't usually simple. The iPhone Developer Library has an example project including some symmetric crypto using Objective-C.
Essentially though, you follow these kinds of steps (not specific to any particular crypto API).
init_crypto_library();
key k = crypto_load_key("my/key.dat");
cipher c = crypto_init_cipher(k, CBCMODE);
while ( char* buf == get_plaintext() ){
crypto_encrypt( c, buf );
}
char* encrypted = crypto_finalize_cipher( c );
crypto_unload_key( k );
You should always try to consider how safe the secret key is in your system. You can't really trust keeping it safe forever.
精彩评论