smscryptosymbiancppuicrypter.c

来自「symbian 发送短信例子 S60 SMS Sample」· C语言 代码 · 共 53 行

C
53
字号
/*
* ============================================================================
*  Name     : SMSCryptoSymbianCppUICrypter.c
*  Part of  : Open C SMS Crypto Example
*  Created  : 05/25/2007 by Forum Nokia
*  Version  : 1.0
*  Copyright: Nokia Corporation
* ============================================================================
*/

#include "SMSCryptoSymbianCppUICrypter.h"
#include <stddef.h>
#include <openssl/rc4.h>
#include <openssl/md5.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 * Encrypt a SMS message using Open C libcrypt
 */
void s60_encrypt(int len, unsigned char* in, unsigned char* crypted, unsigned char* password, int passlen)
{
   unsigned char digest[MD5_DIGEST_LENGTH];
   RC4_KEY key;
   
   MD5(password, passlen, digest);
   
   RC4_set_key(&key, MD5_DIGEST_LENGTH, digest);
   RC4(&key, len, in, crypted);
}

/**
 * Decrypt a SMS message using Open C libcrypt
 */
void s60_decrypt(int len, unsigned char* in, unsigned char* decrypted, unsigned char* password, int passlen)
{
   unsigned char digest[MD5_DIGEST_LENGTH];
   RC4_KEY key;
   
   MD5(password, passlen, digest);
   
   RC4_set_key(&key, MD5_DIGEST_LENGTH, digest);
   RC4(&key, len, in, decrypted);
}

#ifdef __cplusplus
}
#endif

// End of File

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?