rsa_san.h
资源名称:rsa.rar [点击查看]
上传用户:sjzccgj
上传日期:2014-10-18
资源大小:17k
文件大小:1k
源码类别:
CA认证
开发平台:
Visual C++
- // This is a slow but easy RSA encryption class
- // By sanicle,2005.12
- // 3mn@3mn.net
- #include "vlong.h"
- #define PRIME_COUNT 1000000
- class RSA_san
- {
- public:
- char r1[70];
- char r2[70];
- vlong n,e,d,p,q;
- vlong result;
- vlong prime_table[PRIME_COUNT];
- int prime_table_use;
- int prime_p_index;
- int prime_q_index;
- RSA_san();
- ~RSA_san();
- vlong encrypt( const vlong& x );
- vlong decrypt( const vlong& y );
- int RSA_san_en(char * s,unsigned n);
- int RSA_san_en_byte(char b);
- int RSA_san_dn(char * s,unsigned n);
- int RSA_san_dn_hexstring(char * s);
- int RSA_san_en_hexstring(char * s);
- char* hexstring2string(char * h);
- char* string2hexstring(char * s);//,unsigned len)
- char* vlong2hexstring( const vlong& v );
- //unsigned* vlong2ints( const vlong& v );
- char* vlong2shortints( const vlong& v );
- int set_e(char * e);
- int force_e(char * r,unsigned len);
- int force_d(char * r,unsigned len);
- int force_n(char * r,unsigned len);
- int update_pq(char * ra,char * rb);
- private:
- char s[255];
- unsigned u[127];
- void find_prime();
- void random_e();
- void calculate_d();
- };