简体   繁体   English

在C#中加密密码,然后在php中解密

[英]Encrypt a password in C# and decrypt it in php

I want to use following encryption method in C#. 我想在C#中使用以下加密方法。 but I don't know whether it is available or not and how to use it exactly. 但我不知道它是否可用以及如何正确使用它。 Because I am much more familiar in web :'(. Task is I have to decrypt the user password where it encrypted in desktop app.(written in C#) and send as a json object. Using my php script I have to decode the json object and also decrypt password. Plz help. If this is not achievable plz suggest me a solution to use. 因为我对Web更加熟悉:'(。任务是我必须解密在桌面应用程序中加密的用户密码(用C#编写),并作为json对象发送。使用我的php脚本,我必须对json进行解码对象并解密密码,请帮助。如果无法实现,请给我一个解决方案。

I want to use this code in C# 我想在C#中使用此代码

$key = '12345bcde';
$password = 'myPass@1001';

$encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $password, MCRYPT_MODE_CBC, md5(md5($key))));

I got encryption and decryption method from here 我从这里得到了加密和解密的方法

The .net framework contains System.Security.Cryptography.Rijndael which will do the task. .net框架包含System.Security.Cryptography.Rijndael ,它将执行此任务。

BTW: normally you don't decrypt passwords. 顺便说一句:通常您不会解密密码。 You use a one way function (preferrably with some salt) to encrypt the passwords and compare the encrypted password. 您使用一种单向功能(最好添加一些盐)来加密密码并比较加密的密码。

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

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