简体   繁体   English

Windows Phone 7中的AES加密

[英]AES Encryption in Windows Phone 7

I'm trying to implement this utility class I found on gutgames by James Craig, (you can view the class here ) with Windows Phone 7. 我正在尝试实现我在James Craig的gutgames上发现的实用程序类,(您可以在此处查看该类)使用Windows Phone 7。

I had to replace all the references to System.Text.Encoding.ASCII to System.Text.Encoding.UTF8 since ASCII apparently is not supported in WP7. 我不得不将对System.Text.Encoding.ASCII的所有引用替换为System.Text.Encoding.UTF8,因为WP7中显然不支持ASCII。 Besides that I'm still getting some errors because of references / namespaces not being found: 除此之外,由于找不到引用/名称空间,我仍然遇到一些错误:

  • PasswordDeriveBytes PasswordDeriveBytes
  • RijndaelManaged Rijndael管理
  • CipherMode 密码模式

Firstly I don't have a clue what this is, secondly, are there any classes that I can use to replace these that indeed will be available in the Windows Phone 7 framework? 首先,我不知道这是什么,其次,是否有任何类可以替代Windows Phone 7框架中确实可用的类?

Thanks! 谢谢!

The PasswordDeriveBytes , RijndaelManaged and CipherMode types are not implemented in Silverlight. Silverlight中未实现PasswordDeriveBytesRijndaelManagedCipherMode类型。 So you need to provide your own implementation of these types. 因此,您需要提供自己的这些类型的实现。

BUT I guess that use can use AesManaged class to do what you want. 但是我想使用可以使用AesManaged类来做您想要的事情。 From MSDN page: 从MSDN页面:

The AES algorithm is essentially the Rijndael symmetric algorithm with a fixed block size and iteration count. AES算法本质上是具有固定块大小和迭代计数的Rijndael对称算法。 This class functions the same way as the .NET Framework RijndaelManaged class but limits blocks to 128 bits and does not allow feedback modes. 该类的功能与.NET Framework RijndaelManaged类的功能相同,但是将块限制为128位,并且不允许使用反馈模式。

The cipher mode is always CBC, and the padding mode is always PKCS7. 密码模式始终为CBC,填充模式始终为PKCS7。

As @ie. 作为@ie。 already mentioned, these types are not included in Silverlight. 已经提到,这些类型不包含在Silverlight中。

If you want to use them, you can download WP7 build of "bouncy castle library". 如果要使用它们,可以下载“充气城堡库”的WP7版本。

See this topic: Using Bouncy Castle on Windows Phone 7 请参阅主题: 在Windows Phone 7上使用Bouncy Castle

The download links are at the bottom of this page. 下载链接在此页面的底部。 Direct link (BouncyCastle.Crypto.WP7 or BouncyCastle.Crypto.WP71) 直接连结 (BouncyCastle.Crypto.WP7或BouncyCastle.Crypto.WP71)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM