使用RSA算法對數(shù)據(jù)進(jìn)行加密的方法
具體方法如下:
#ifndef ENCRYPT_H
#define ENCRYPT_H
/*在一個安全實現(xiàn)中,Huge 最少要400位10進(jìn)制數(shù)字*/
typedef unsigned long Huge;
/*為RSA公鑰定義一個數(shù)據(jù)結(jié)構(gòu)*/
typedef struct RsaPubKey_
{
Huge e;
Huge n;
}RsaPubkey;
/*為RSA私鑰定義一個數(shù)據(jù)結(jié)構(gòu)*/
typedef struct RsaPriKey_
{
Huge d;
Huge n;
}RsaPriKey;
/*函數(shù)聲明*/
void des_encipher(const unsigned char *plaintext, unsigned char *ciphertext, const unsigned char *key);
void des_decipher(const unsigned char *ciphertext, unsigned char *plaintext, const unsigned char *key);
void rsa_encipher(Huge plaintext, Huge *ciphertext, RsaPubKey pubkey);
void rsa_decipher(Huge ciphertext,Huge *plaintext, RsaPriKey prikey);
#endif