比较C#和ColdFusion之间的密码哈希(CFMX_COMPAT) [英] Compare password hashes between C# and ColdFusion (CFMX_COMPAT)

查看:218
本文介绍了比较C#和ColdFusion之间的密码哈希(CFMX_COMPAT)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储在表中,并且由下面的ColdFusion脚本放在那里一个密码散列 -

I have a password hash that is stored in a table and is put there by the following coldfusion script-

#Hash(Encrypt(Form.UserPassword,GetSiteVars.EnCode))#

我想一个C#应用程序中添加一些外部功能。我希望能够利用已经存在的,这样我可以验证用户数据的优势。有谁知道我可以复制上面的ColdFusion code在C#?

I am trying to add some outside functionality within a c# application. I would like to be able to take advantage of the data that already exists so that I can authenticate users. Does anyone know how I can replicate the above coldfusion code in c#?

感谢您的任何想法。

推荐答案

我会离开原来的答复内容下面的历史参考,但应注意的是,这不是一个工作的答案原来的问题

I'll leave the original answer content below for historical reference, but it should be noted that this is NOT a working answer to the original question.

相反,看看在2011年1月该线程中得票最多的答案,按@Terrapin我希望OP认为这并能改变接受的答案。哎呀,我什旗MODS的,看什么都可以搞定这个问题。

Instead, see the top-voted answer in this thread, by @Terrapin in January 2011. I hope the OP sees this and can change the accepted answer. Heck, I'll even flag the mods to see if anything can be done about this.

要建立在由爱德华·史密斯的答案,并通过czuroski的后续的评论,这里是我的解决方案。

To build on the answer by Edward Smith, and the follow-up comments by czuroski, here is my solution.

首先,你需要在C#中的XOR功能,我从<一个取href=\"http://www.eggheadcafe.com/tutorials/aspnet/8b53894c-a889-4914-8c46-122980cc44ae/simple-xor-encryption.aspx\"相对=nofollow>这里并略作修改。

First, you need an XOR function in C#, which I've taken from here and modified slightly.

using System;
using System.Collections.Generic;
using System.Text;

namespace SimpleXOREncryption
{    
    public static class EncryptorDecryptor
    {
        public static string EncryptDecrypt(string textToEncrypt, int key)
        {            
            StringBuilder inSb = new StringBuilder(textToEncrypt);
            StringBuilder outSb = new StringBuilder(textToEncrypt.Length);
            char c;
            for (int i = 0; i < textToEncrypt.Length; i++)
            {
                c = inSb[i];
                c = (char)(c ^ key);
                outSb.Append(c);
            }
            return outSb.ToString();
        }   
    }
}

然后,取XOR和基带64 code那么它的结果。当你有一个字符串,MD5哈希它。其结果应符合由原来的code段的结果:

Then, take the result of the XOR and base-64 encode it. After you have that string, MD5 hash it. The result should match the result from the original code snippet:

#Hash(Encrypt(Form.UserPassword,GetSiteVars.EnCode))#

这篇关于比较C#和ColdFusion之间的密码哈希(CFMX_COMPAT)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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