//使用本代码需要先下载LibTomMath和LibTomCrypt库
//编译LibTomMath、LibTomCrypt后生成lib文件
//在本工程的包含目录中添加LibTomCrypt的头文件目录
//链接器中添加LibTomCrypt、LibTomMath的Lib文件
#include <Windows.h>
#include <stdio.h>
#define LTM_DESC
#include <tomcrypt.h>
#include <time.h>
#define PTSIZE 87
#define CPSIZE 1024
#define BUFFERSIZE 1024
//按照16进制方式打印字符串
void strprint(const char * name,unsigned char *msg,int len);
//对比两个字符数组如果完全匹配返回0,否则返回负数
int msgcmp(unsigned char *msg1,unsigned long l1,unsigned char *msg2,unsigned long l2);
int main(void)
{
char c;
int prng_idx,hash_idx,err;
unsigned char pt[PTSIZE],pt1[CPSIZE],cp[CPSIZE];
unsigned char out[BUFFERSIZE];
unsigned long l1,l2;
rsa_key key;
rsa_key pubkey,prikey;
unsigned char pubkeybuffer[BUFFERSIZE], prikeybuffer[BUFFERSI
使用LibTomCrypt实现RSA加密解密算法,公钥、私钥分离
于 2019-03-15 16:20:07 首次发布