对RSA 还不是很熟悉。 只是做到了用。实现的情况 比较奇怪  3方运算, 一方是c/c++ linux.  一方是 asp.net c#  还有一方是javascript我感觉真是太夸张了。  javascript 里面 找打了一个实现 是RSA (key, publickey) 这样的方式来加解密。  但是c# 里面 很夸张的是 n 多个参数  如下。  很显然 可以将这些参数 组成 publickey 和priavtekey 不知道该如何组合?
谢谢。RSAParameters 类型公开的成员。 公共字段 
  名称  说明  
   D  表示 RSA 算法的 D 参数。 
   DP  表示 RSA 算法的 DP 参数。 
   DQ  表示 RSA 算法的 DQ 参数。 
   Exponent  表示 RSA 算法的 Exponent 参数。 
   InverseQ  表示 RSA 算法的 InverseQ 参数。 
   Modulus  表示 RSA 算法的 Modulus 参数。 
   P  表示 RSA 算法的 P 参数。 
   Q  表示 RSA 算法的 Q 参数。 涉及c#了。  但是 我现在要在javascript下来干活啊. 所以不知道如何做javascript 的脚本如下:http://www.ohdave.com/rsa/function RSAKeyPair(encryptionExponent, decryptionExponent, modulus)
{
this.e = biFromHex(encryptionExponent);
this.d = biFromHex(decryptionExponent);
this.m = biFromHex(modulus);
// We can do two bytes per digit, so
// chunkSize = 2 * (number of digits in modulus - 1).
// Since biHighIndex returns the high index, not the number of digits, 1 has
// already been subtracted.
this.chunkSize = 2 * biHighIndex(this.m);
this.radix = 16;
this.barrett = new BarrettMu(this.m);
}function twoDigit(n)
{
return (n < 10 ? "0" : "") + String(n);
}function encryptedString(key, s)
// Altered by Rob Saunders ([email protected]). New routine pads the
// string after it has been converted to an array. This fixes an
// incompatibility with Flash MX's ActionScript.
{
var a = new Array();
var sl = s.length;
var i = 0;
while (i < sl) {
a[i] = s.charCodeAt(i);
i++;
} while (a.length % key.chunkSize != 0) {
a[i++] = 0;
} var al = a.length;
var result = "";
var j, k, block;
for (i = 0; i < al; i += key.chunkSize) {
block = new BigInt();
j = 0;
for (k = i; k < i + key.chunkSize; ++j) {
block.digits[j] = a[k++];
block.digits[j] += a[k++] << 8;
}
var crypt = key.barrett.powMod(block, key.e);
var text = key.radix == 16 ? biToHex(crypt) : biToString(crypt, key.radix);
result += text + " ";
}
return result.substring(0, result.length - 1); // Remove last space.
}function decryptedString(key, s)
{
var blocks = s.split(" ");
var result = "";
var i, j, block;
for (i = 0; i < blocks.length; ++i) {
var bi;
if (key.radix == 16) {
bi = biFromHex(blocks[i]);
}
else {
bi = biFromString(blocks[i], key.radix);
}
block = key.barrett.powMod(bi, key.d);
for (j = 0; j <= biHighIndex(block); ++j) {
result += String.fromCharCode(block.digits[j] & 255,
                              block.digits[j] >> 8);
}
}
// Remove trailing null, if any.
if (result.charCodeAt(result.length - 1) == 0) {
result = result.substring(0, result.length - 1);
}
return result;
}我应该如何做啊?

解决方案 »

  1.   

    http://www.cnblogs.com/Moosdau/archive/2007/09/28/908852.html
      

  2.   

    我的意思是 如何做验证呢?
    javascript 
    ÎÒÈçºÎÔÚjavasctip ½øÐÐÑéÖ¤ÄØ£¿
    C# ÀïÃæûÓе½³öÒ»¸ö¹«Ô¿×Ö·û´®£¬ Ëûµ½´¦ÁË module ºÍexp...
      

  3.   

    http://www.cnblogs.com/Moosdau/archive/2007/09/28/908852.html
      

  4.   

    我想你们误会我的意思了
    我不是单纯的要一个c# 的RSA 加密解密。
    这样的算法 在msdn 里面 我已经找到了。 而且经过测试已经成功了比如 
    RSACryptoServiceProvider rsa=new RSACryptoServiceProvider(1024);
    RSAParameters keys=rsa.ExportParameters(true);我已经设计出一个随机的密钥对  长度1024.我用c# 已经可以成功加密解密 而且也能正确将里面的所有参数
    存储出来。
    问题是 存储出来的参数如何 用在javascript 里面呢?因为参数很多
     D     表示   RSA   算法的   D   参数。   
          DP     表示   RSA   算法的   DP   参数。   
          DQ     表示   RSA   算法的   DQ   参数。   
          Exponent     表示   RSA   算法的   Exponent   参数。   
          InverseQ     表示   RSA   算法的   InverseQ   参数。   
          Modulus     表示   RSA   算法的   Modulus   参数。   
          P     表示   RSA   算法的   P   参数。   
          Q     表示   RSA   算法的   Q   参数。   我不知道 javascript 的算法如何使用这些参数。我找到的那个RSA 很简单,只有一个密钥 一个公钥。 所以我希望把
    密钥公钥保存成那种形式。如果有可以使用RSA 这种形式的js 那就求之不得了。
    谢谢