0

背景:我已经获得了一个私钥(XXX.key)和它的密码。另外,我有一个为使用 windows mobile 6 (.NET Compact Edition 3.5) 的 PocketPC 开发的应用程序。 场景:我需要使用以下步骤对消息进行签名: 1. 使用 SHA1 算法对消息进行加密。2. 使用提供的私钥,使用 RSA 算法对摘要进行签名。3. 将结果转换为其等效的以 64 位数字编码的字符串表示。我可以通过以下几行来实现第一步:

// Step 1
string message = "this message will be encrypted";
byte[] messageBytes = Encoding.UTF8.GetBytes(message);
SHA1 sha1 = SHA1.Create();
byte[] digestion = sha1.ComputeHash(messageBytes, 0, messageBytes.Length);

// Step 2 Here I need to sign with the private key.
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();

// Step 3
string signedMessage = Convert.ToBase64String();

值得一提的是,这些步骤必须在无法访问互联网的 Pocket 的应用程序中实现。我的问题是我不知道如何将私钥放入 RSA 算法中。另外,我不是安全方面的专家。请不要告诉我为什么我需要这样做;我不是这样设计的。有谁知道实施第二步?提前致谢。

4

0 回答 0