I have a database with user passwords that are encrypted via cfusion_encrypt(). I need to do a login alternative for the ColdFusion code in C#. Is there any easy way how to emulate this in C# so I will be able to compare encrypted values of user passwords and match them to the ColdFusion values?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
This may not answer your question, but the best bet from what I can tell would be to code up a Coldfusion loop to:
I'm not aware of any C# native equivalents to cfusion_decrypt and cfusion_encrypt, but hopefully the folks here might be able to point you towards one.
If you require the built-in "cfusion_encrypt" & "cfusion_decrypt" undocumented functions that Adobe silently deprecated in ColdFusion 11, a developer converted them into UDFs back in 2005.
http://www.barneyb.com/barneyblog/2005/10/28/cfusion_encryptcfusion_decrypt-udfs/
Here's sample script on how to test it:
Probably the simplest solution is to create ColdFusion service layer which will interact with your db, but you need to work on security for this service, of course if you want to keep passwords the way they are now.
If you don't want a CF service layer, then what you need to do is to figure out what kind of encryption is being used. If it is one of the common hash algorithms like: MD5 SHA1 SHA256 SHA384 SHA512 then you'll have a chance of solving this.
I found an old article on www.fusionauthority.com which stated:
The poorly named
cfusion_encrypt()
is not encryption at all. It is an internal, legacy obfuscation algorithm, whose use is strongly discouraged.Essentially it just xor's the bytes, similar to the method described here (Ignore the mention of
cfmx_compat
, that is a different legacy algorithm). It extracts the bytes of a plain text string. Then pads the suppliedkey
string to the same length, and again extracts the bytes. Finally it xor's the two byte arrays and encodes the result as hex:The
cfusion_decrypt()
function does essentially the same thing only decoding the hex string into bytes first, and returns the "de-obfuscated" result as a plain string instead of hex.Now you can see why its use is discouraged. As @MartyPine and others suggested, the better option is to have the CF side make a backup, then run the passwords through
cfusion_decrypt
and hash() them instead. Not only is it a better way to store passwords, it also has the benefit of being compatible with C#, or any other language that supports the standard algorithms.