C#相当于此ColdFusion解密功能 [英] C# equivalent to this ColdFusion Decrypt function

查看:139
本文介绍了C#相当于此ColdFusion解密功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ColdFusion的一个函数,加密和解密密码。我需要有人看功能,点我还是写我一个C#等价的。它需要一个项目尽快这样我就可以把你扔一些现金通过PayPal如果你能帮助

I have a function in ColdFusion that encrypts and decrypts passwords. I need someone to look at the function and point me to or write me a c# equivalent. It is needed for a project asap so I can throw you some cash through paypal if you can help.

CF功能:

Decrypt("CLbtkjNkcofJ5D8s4Ri7nA==", "EajmplPP8DHg6Tqq8BVRMw==", "AES", "Base64")

这是真正的功能,具有从测试侧,也需要转换真实数据

This is the real function, with real data from a test side, that needs to be converted.

不限帮助将是真棒..和盈利能力。

Any help would be awesome .. and profitable.

谢谢,
甄子丹

Thanks, Donnie

推荐答案

您的出发点是系统。 Security.Cryptography.Aes

但这些东西可以得到相当多毛的,例如,你需要知道要使用的模式。由于您的例子没有显示的IV(初始化向量),你应该使用 CipherMode.ECB

But these things can get quite hairy, for example you need to know which mode to use. Since your example is not showing an IV (initialization vector) you should use CipherMode.ECB.

下面是一些测试代码,我将它留给你的一个不错的可重复使用的功能

Here is some test code, I will leave it to you to wrap this up in a nice re-usable function

  byte[] key = Convert.FromBase64String("EajmplPP8DHg6Tqq8BVRMw==");
  byte[] encryptedData = Convert.FromBase64String("CLbtkjNkcofJ5D8s4Ri7nA==");

  Aes aes = Aes.Create();
  aes.Mode = CipherMode.ECB;

  using (var ms = new MemoryStream())
  {
    using (var cs = new CryptoStream(ms, aes.CreateDecryptor(key, null), CryptoStreamMode.Write))
    {
      cs.Write(encryptedData, 0, encryptedData.Length);
    }
    byte[] decryptedData = ms.ToArray();
    string clearText = Encoding.ASCII.GetString(decryptedData);
    Console.WriteLine(clearText);
  }



答案=>AccessOne

The answer => "AccessOne"

这篇关于C#相当于此ColdFusion解密功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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