//private void RetriveDiness() //{ // var regex = Regex.Match(driver.PageSource, "\"CSRF_ID_LIST\":\"(.+?)\""); // if (regex.Success) // { // diness = regex.Result("$1"); // diness = Regex.Replace(diness, @"(.{32})", "$1-").Trim('-'); // string[] dinessList = diness.Split('-'); // diness = dinessList[dinessList.Length - 1]; // logger.Info($"[{param.AccountNo}] - Retrive diness from page success. Diness Key - {diness}"); // } // else // { // logger.Error($"[{param.AccountNo}] - Unable to retrive diness from page"); // } //} private string GetCode(string url, CookieContainer cookie) { var handler = new HttpClientHandler() { AllowAutoRedirect = true, UseCookies = true, CookieContainer = cookie }; http = new HttpClient(handler); var result = http.GetAsync(url).Result.Content.ReadAsByteArrayAsync().Result; string code; try { //DeCode decode = new DeCode(); var decode = new DecodeClass(ProjectPath.BIDVProject.pro); using (MemoryStream ms1 = new MemoryStream(result)) { using (Bitmap bmp = (Bitmap)Image.FromStream(ms1)) { ms1.Close(); code = decode.DeCode(bmp); } } if (code.Length != 5) { throw new Exception("自家打码数位不符合"); } return(code); } catch (Exception ex) { logger.Error($"[{this.GetType().Name}]自家大码异常. {ex.Message}"); var decode = new DeCode(); code = new DeCode().GetCode(5, CaptchaType.LetterNumber, result); logger.Info($"[{this.GetType().Name}]验证码 : {code}"); if (code.Length != 5) { logger.Info($"[{this.GetType().Name}]登录失败.验证码识别失败[{decode.GetCodeName(decode.Dama.f_codeuse)}]-{code}"); throw new Exception($"登录失败.验证码识别失败[{decode.GetCodeName(decode.Dama.f_codeuse)}]-{code}"); } return(code); } }
private string GetCode(string url, CookieContainer cookie) { var handler = new HttpClientHandler() { AllowAutoRedirect = true, UseCookies = true, CookieContainer = cookie }; http = new HttpClient(handler); var result = http.GetAsync(url).Result; DeCode decode = new DeCode(); string code = decode.GetCode(5, JZLibraries_Bank.DeCode.CaptchaType.LetterNumber, result.Content.ReadAsByteArrayAsync().Result); logger.Info($"[{this.GetType().Name}]验证码 : {code}"); if (code.Length != 5) { logger.Info($"[{this.GetType().Name}]登录失败.验证码识别失败[{decode.GetCodeName(decode.Dama.f_codeuse)}]-{code}"); throw new Exception($"登录失败.验证码识别失败[{decode.GetCodeName(decode.Dama.f_codeuse)}]-{code}"); } return(code); }
static void Main(string[] args) { Encoding unicode = Encoding.Unicode; Console.OutputEncoding = unicode; Console.Write("Enter key "); string key = Console.ReadLine(); Console.WriteLine("Word to encode "); string word = Console.ReadLine(); EnCode incode = new EnCode(); string incodeword = incode.GetWord(key, word); DeCode decode = new DeCode(); string decodeword = decode.GetWord(key, incodeword); Console.WriteLine("Encoding word " + word); Console.WriteLine("Result: " + incodeword); Console.WriteLine(decodeword); }