如何在 Windows Phone 7 中使用 AES/ECB/PKCS7Padding 算法? [英] How use AES/ECB/PKCS7Padding algorithm in Windows Phone 7?

查看:25
本文介绍了如何在 Windows Phone 7 中使用 AES/ECB/PKCS7Padding 算法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Windows 手机开发的新手.如何在 WP7 中使用 AES/ECB/PKCS7Padding 算法?.

I am new in windows phone development. How can I use AES/ECB/PKCS7Padding algorithm in WP7 ?.

在谷歌搜索时,我看到很多关于充气城堡的建议.但我并没有清楚地了解这座充气城堡.这是算法吗?

While googled I saw many suggested about Bouncy Castle. But I did not clearly understood about this Bouncy Castle. Is this an algorithm ?.

我需要加密/解密密码以发送到服务器.在所有其他手机(Android、iPhone、Blackberry)中,我们为此使用 AES/ECB/PKCS7Padding 算法.它们都为我们的输入提供相同的加密/解密结果.但在 Windows Phone 中,我使用 AesManaged Class 进行加密.但它给出了不同的加密结果.在 msdn 文档中 (MSDN 文档)关于 AESManaged 类,他们说密码模式始终为 CBC,填充模式始终为 PKCS7".我想也许这就是为什么我在这里得到与其他手机不同的加密结果.

I need to encrypt/decrypt password for sending to server. In all other phone (Android, iPhone, Blackberry), we use AES/ECB/PKCS7Padding algorithm for this. They all give same ecrypted/decrypt result for our input. But in windows phone I used AesManaged Class for the encryption. But it gives different encrypted result. In the msdn documentation (MSDN documentation) about AESManaged class they said "The cipher mode is always CBC, and the padding mode is always PKCS7". I think maybe thats why here I am getting different encrypted result comparing to other phones.

这是这里的问题吗?.如果是,那么我如何在 WP7 中使用 AES/ECB/PKCS7Padding 算法?

Is that the problem here ?. If its, then how can I use AES/ECB/PKCS7Padding algorithm in WP7 ?

我在 AesManaged 类中没有看到任何用于设置密码模式的属性.

I dont see any property for setting the cipher mode in AesManaged class.

谢谢.

推荐答案

如果你想在 Windows Phone 中使用 AES/ECB/PKCS7Padding,你应该使用 Bouncy Castle 库.

If you want to use AES/ECB/PKCS7Padding in Windows Phone, you should use Bouncy Castle library.

这个库不是专门为 Windows Phone 制作的,你不能使用来自 Bouncy Castle 站点的 dll.相反,您应该从 这里.(文章底部两个链接)

This library wasn't made exactly for Windows Phone, and you can't use the dll from Bouncy Castle site. Instead, you should download the WP7-ported library from here. (two links at the bottom of the article)

现在,您可以使用 Org.BouncyCastle.Crypto.IBufferedCipher 类型.

Now, you can use Org.BouncyCastle.Crypto.IBufferedCipher type.

cipher = CipherUtilities.GetCipher("AES/ECB/PKCS7"); // or PKCS7PADDING, no matter
cipher.Init(false, new KeyParameter(key)); // or something else

那么你应该使用这个变量.

Then you should work with this variable.

是的,

密码模式总是CBC,填充模式总是PKCS7"

"The cipher mode is always CBC, and the padding mode is always PKCS7"

这就是你得到错误结果的原因.

that's why you are getting wrong result.

这篇关于如何在 Windows Phone 7 中使用 AES/ECB/PKCS7Padding 算法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆