www.pudn.com > sanpack_rsa_vs2003sln_src.rar > Class1.cs
using System;
using System.Runtime.InteropServices;
using System.Collections;
using System.Text;
namespace sanpack_rsa_csclass
{
public class Sanpack_rsa
{
public static string s1;
public static string s2;
public static System.Collections.ArrayList charlist=new ArrayList();
public static System.Collections.ArrayList hextxtlist=new ArrayList();
public static System.Collections.ArrayList result_hexstrings=new ArrayList();
public static uint RSAstep;
public static uint RSAprimeplen1;
public static uint RSAprimeplen2;
[DllImport("sanpack_rsa.dll")]
public static extern string get_Version();
[DllImport("sanpack_rsa.dll")]
public static extern int refresh_RSA_san(string a,string b);
[DllImport("sanpack_rsa.dll")]
public static extern int start_RSA_san();
[DllImport("sanpack_rsa.dll")]
public static extern int finish_RSA_san();
[DllImport("sanpack_rsa.dll")]
public static extern int RSA_san_en(byte []b,uint n);
[DllImport("sanpack_rsa.dll")]
public static extern int RSA_san_en_byte(byte b);
[DllImport("sanpack_rsa.dll")]
public static extern int RSA_san_dn(byte []b,uint n);
[DllImport("sanpack_rsa.dll")]
public static extern int RSA_san_en_hexstring(string s);
[DllImport("sanpack_rsa.dll")]
public static extern int RSA_san_dn_hexstring(string s);
[DllImport("sanpack_rsa.dll")]
public static extern string get_p();
[DllImport("sanpack_rsa.dll")]
public static extern string get_q();
[DllImport("sanpack_rsa.dll")]
public static extern string get_n();
[DllImport("sanpack_rsa.dll")]
public static extern string get_e();
[DllImport("sanpack_rsa.dll")]
public static extern string get_d();
[DllImport("sanpack_rsa.dll")]
public static extern string get_result_string();
[DllImport("sanpack_rsa.dll")]
public static extern byte get_result_byte(uint i);
[DllImport("sanpack_rsa.dll")]
public static extern string get_result_hexstring();
[DllImport("sanpack_rsa.dll")]
public static extern string string2hexstring(string s);
[DllImport("sanpack_rsa.dll")]
public static extern int set_e_fromhexstring(string s);
[DllImport("sanpack_rsa.dll")]
public static extern int force_e(string s,uint l);
[DllImport("sanpack_rsa.dll")]
public static extern int force_d(string s,uint l);
[DllImport("sanpack_rsa.dll")]
public static extern int force_n(string s,uint l);
public static int GetRandomString()
{
Random rnd = new Random();
Byte[] b = new Byte[System.Math.Max(RSAprimeplen1,RSAprimeplen2)];
s1="";
s2="";
//next we'll produce 2 random string
//the string may have zero_code chars in it
//to prevent from cutting the string
//we change 00 into 41 in s1
// 00 into 42 in s2
//this work has been done in class RSA_san (sanpack_rsa.dll)
//while(s1.Length<35)
//{
for(int i=0;i