简体   繁体   English

如何在WinRT应用中加密字符串,在WCF服务中解密?

[英]How to Encrypt string in WinRT app, decrypt in WCF service?

I'm wondering how to encrypt a string in my Windows 8 app, and then how to decrypt it in a WCF service. 我想知道如何在Windows 8应用程序中加密字符串,然后在WCF服务中如何解密字符串。 I want to do this for security reasons. 出于安全原因,我想这样做。 I'm new to encryption and it's very confusing for me. 我是加密技术的新手,这对我来说很混乱。 I do know, (correct me if I'm wrong) that hashing algorithm's like MD5 and SHA1 cannot be reversed to get the original value of a string. 我确实知道(如果我错了,请纠正我),像MD5和SHA1这样的哈希算法无法反转以获取字符串的原始值。 So if I were to use one of those algorithms, then how can I get the original value in my web service? 因此,如果我要使用其中一种算法,那么如何在Web服务中获得原始值?

Also, if you can give me any resources on encryption and other related subjects, then that'd be awesome. 另外,如果您可以给我有关加密和其他相关主题的任何资源,那真是太棒了。 Thank you for you time! 谢谢您的时间!

If you want to prevent eavesdropping on the communication between your app and the service, I would suggest you to just use SSL/TLS ( https ) as it was designed to do exactly that. 如果您想防止窃听您的应用程序与服务之间的通信,我建议您仅使用SSL / TLS( https ),因为它正是为此而设计的。

If for some reason you really want/need to encrpt a string before sending it across the wire, asymetric encryption (RSA) would be your best choice. 如果出于某种原因您真的希望/需要在通过网络发送字符串之前先加密一个字符串,那么不对称加密(RSA)将是您的最佳选择。 You can look at this SO answer for details on that, including the export/import of the key. 您可以查看此SO答案以获取有关细节的详细信息,包括密钥的导出/导入。

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

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