|
悬赏1金钱未解决
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
namespace ConsoleApplication1 { class Program { static void Main(string[] args) { var key = "951a9235ccbb899cfc553030b4a68c0d"; // 从请求中获取的key var increment = 3; // 从b05395426617a666.swf中获取的常量INCREMENT var loc2 = Encript(key); loc2 = loc2.Substring(0, 6); var loc3 = int.Parse(loc2, System.Globalization.NumberStyles.HexNumber); loc3 = loc3 + increment; // 期待的sig值为:8daa0c34bcac38b5910cab2f296600bd var sig = MD5(loc3.ToString()); Console.WriteLine(sig); // 输出:8daa0c34bcac38b5910cab2f296600bd,成功! Console.ReadLine(); } /// <summary> /// C#实现的MD5加密算法 /// </summary> /// <param name="input"></param> /// <returns></returns> static string MD5(string input) { byte[] result = new byte[input.Length]; try { var md5 = new MD5CryptoServiceProvider(); var computedHash = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(input)); System.Text.StringBuilder sb = new System.Text.StringBuilder(); for (int i = 0; i < computedHash.Length; i++) { sb.Append(computedHash.ToString("x2")); // hex format } return sb.ToString(); } catch { return ""; } } /// <summary> /// EncriptLib.encript方法 /// </summary> /// <param name="input"></param> /// <returns></returns> static string Encript(string input) { var loc2 = MD5(input); loc2 = MD5(loc2); loc2 = loc2.Substring(1, 6); var loc3 = int.Parse(loc2, System.Globalization.NumberStyles.HexNumber); loc2 = MD5(loc2); return loc2; } } }
不是单纯的md5 请仔细看代码 |
|