开发者

Help decrypting in ColdFusion passwords created in .NET

I have a SQL db storing passwords that were encrypted through a .NET application, that I need to decrypt through a ColdFusion app. I just can't seem to get things set upproperly for th开发者_C百科e CF decryption to work. Any help would by appreciated. Thanks.

The .NET decryption code is:

public string Decrypt(string input) 
 { 
  try 
  { 
   DESCryptoServiceProvider des = new DESCryptoServiceProvider(); 

   int ZeroBasedByteCount = (input.Length / 2); 

   //Put the input string into the byte array 
   byte[] inputByteArray = new byte[ZeroBasedByteCount]; 

   int i; 
   int x; 

   for (x = 0;x<ZeroBasedByteCount;x++) 
   { 
    i = (Convert.ToInt32(input.Substring(x * 2, 2), 16)); 
    inputByteArray[x] = (byte)i; 
   } 

   //Create the crypto objects 
   des.Key = ASCIIEncoding.ASCII.GetBytes(key); 
   des.IV = ASCIIEncoding.ASCII.GetBytes(key); 
   MemoryStream ms = new MemoryStream(); 
   CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write); 

   //Flush the data through the crypto stream into the memory stream 
   cs.Write(inputByteArray, 0, inputByteArray.Length); 
   cs.FlushFinalBlock(); 

   //Get the decrypted data back from the memory stream 
   StringBuilder ret = new StringBuilder(); 

   foreach(byte b in ms.ToArray()) 
   { 
    ret.Append((char)b); 
   } 

   return ret.ToString(); 

  } 
  catch(Exception ex) 
  { 
   throw(ex); 
   return null; 
  } 
 }


Have you read the docs for the CF Decrypt function and determined what values you need for the encoding, IVorSalt, and/or iterations arguments? (It looks like the algorithm is DES.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜