资源简介
此代码有如下特点:
1 知道解密结果是否正确 省去了在数据里加校验和
2 知道解密后的数据大小 省去了在数据里标明大小
3 在用公钥加密数据时用到了随机数 即每次加密相同的数据结果都不一样 省去了在数据里随机数
4 公钥加密私钥解密 私钥加密公钥解密 一对密钥即可相互传输数据
5 支持512 1024 2048三种级别的加密
更多信息请移步
http: blog csdn net sidyhe article details 39102329">此代码有如下特点:
1 知道解密结果是否正确 省去了在数据里加校验和
2 知道解密后的数据大小 省去了在数据里标明大小
3 在用公钥加密数据时用到了随机数 即每次加密相同的数据结果都不一样 省去了在数据里随机数
4 [更多]
代码片段和文件信息
// RSA.cpp : 定义控制台应用程序的入口点。
// http://blog.csdn.net/sidyhe
#include “stdafx.h“
#include “RSAEuro/rsaeuro.h“
#include
/*
int _tmain(int argc _TCHAR* argv[])
{
R_RSA_PUBLIC_KEY PubKey;
R_RSA_PRIVATE_KEY PriKey;
R_RANDOM_STRUCT RandSt;
R_RSA_PROTO_KEY ProKey;
//生成密钥对
R_RandomCreate(&RandSt);
ProKey.bits = 1024;//512 or 1024 or 2048
ProKey.useFermat4 = 1;
R_GeneratePEMKeys(&PubKey &PriKey &ProKey &RandSt);
if (FILE *f = fopen(“pub.key“ “wb“))
{
fwrite(&PubKey sizeof(PubKey) 1 f);
fclose(f);
}
if (FILE *f = fopen(“pri.key“ “wb“))
{
fwrite(&PriKey sizeof(PriKey) 1 f);
fclose(f);
}
//公钥加密私钥解密
char *TestBuffer = “Hello!Sid!!!“;
{
unsigned char EncryptBuffer[128] = {0};
unsigned char DecryptBuffer[128] = {0};
unsigned int InputLen = sizeof(EncryptBuffer);
unsigned int OutputLen = sizeof(DecryptBuffer);
R_RandomCreate(&RandSt);
RSAPublicEncrypt(EncryptBuffer &InputLen (unsigned char*)TestBuffer strlen(TestBuffer) &PubKey &RandSt);
RSAPrivateDecrypt(DecryptBuffer &OutputLen EncryptBuffer InputLen &PriKey);
printf(“Test1:%s\n“ DecryptBuffer);
}
//私钥加密公钥解密
{
unsigned char EncryptBuffer[128] = {0};
unsigned char DecryptBuffer[128] = {0};
unsigned int InputLen = sizeof(EncryptBuffer);
unsigned int OutputLen = sizeof(DecryptBuffer);
RSAPrivateEncrypt(EncryptBuffer &InputLen (unsigned char*)TestBuffer strlen(TestBuffer) &PriKey);
RSAPublicDecrypt(DecryptBuffer &OutputLen EncryptBuffer InputLen &PubKey);
printf(“Test2:%s\n“ DecryptBuffer);
}
getchar();
return 0;
}
*/
int _tmain(int argc _TCHAR* argv[])
{
R_RSA_PUBLIC_KEY PubKey;
R_RSA_PRIVATE_KEY PriKey;
if (FILE *f = fopen(“pub.key“ “rb“))
{
fread(&PubKey sizeof(PubKey) 1 f);
fclose(f);
}
if (FILE *f = fopen(“pri.key“ “rb“))
{
fread(&PriKey sizeof(PriKey) 1 f);
fclose(f);
}
//
char *TestBuffer = “Hello!Sid!!!“;
{
unsigned char EncryptBuffer[128] = {0};
unsigned char DecryptBuffer[128] = {0};
unsigned int InputLen = sizeof(EncryptBuffer);
unsigned int OutputLen = sizeof(DecryptBuffer);
RSAPrivateEncrypt(EncryptBuffer &InputLen (unsigned char*)TestBuffer strlen(TestBuffer) &PriKey);
RSAPublicDecrypt(DecryptBuffer &OutputLen EncryptBuffer InputLen &PubKey);
printf(“Test2:%s\n“ DecryptBuffer);
}
getchar();
return 0;
}
- 上一篇:CodeSnitch破解版,支持WINCE6.0
- 下一篇:最小二乘法线性非线性拟合
相关资源
- RSA前后台加密解密案例SSM
- UniversalTermsrvPatch-x64
- Rsa 私钥加密 公钥解密
- RSA数字签名源程序
- RSA加密及解密
- BIOS刷新工具Universal Flash Utility V8.95.
- RSA公私钥生成、加解密,支持1024位计
- 华为 h3c 3com ras转16进制工具 sshkey.ex
- RSA加解密在Delphi代码中的实现Demo
- IBM Rational Software Architect Designer 9.5 c
- DXperience Universal 12.1.6 简繁体汉化,本
- RSA-via-OpenSSL-libeay32-master
- 单片机上运行的RSA代码
- Delphi加密算法大全2DES_3DES_3DES3_AES_ba
- openssl中函数RSA_public_encrypt的使用案例
- openssl rsa code
- DXperienceUniversal-12.2.7
- The universal “heartbeat” oscilli
-
Cloning and ex
pression of a peroxiredoxin g - Universal Termsrv.dll Patch 远程桌面多用户
- RSA加密 公钥、密钥生成工具
- 基于.net的RSA私钥加密 公钥解密的源码
- DevExpress DXperience Universal 11.2.10 官方地
- DevExpress DXperience Universal 11.1.7+帮助文
- VS2010环境下使用GMP库-环境配置、大素
- RSA签名算法,PKCS7格式
- IBM Rational Software Architect 9.0
- IBM Rational Software Architect 9.0 百度网盘
- Openssl-win64
- DXperienceUniversal-11.1.7.part05
评论
共有 条评论