const std::string QuickMD5::MD5File(const char* path) { Data data = FileUtils::getInstance()->getDataFromFile(path) ; return MD5String((void*)(data.getBytes()), data.getSize()) ; }
int main(void) { char buf[50000] = {0}; char bufnew[500] = {0}; int sock = 0; char selected = 0; char** option = NULL; int res = 0; void* handle = NULL; char msg[30][1500] = {0}; int i = 0; handle = LoadLibrary("MWGateway.dll"); if (handle == NULL) { puts("can't load the dll.program End"); return 1; } if (handle == NULL) { puts("can't load the dll.program End"); return 1; } MongateConnect = (void*)GetProcAddress(handle, "MongateConnect"); MongateCsSendSms = (void*)GetProcAddress(handle, "MongateCsSendSms"); MongateCsGetSms = (void*)GetProcAddress(handle, "MongateCsGetSms"); MongateDisconnect = (void*)GetProcAddress(handle, "MongateDisconnect"); MongateCsGetSmsEx = (void*)GetProcAddress(handle, "MongateCsGetSmsEx"); puts("connecting to the server..."); MongateCsGetSmsEx(-806,buf); MD5String(bufnew,buf); MongateCsGetSmsEx(-807,bufnew); sock = MongateConnect("61.145.229.26", 8018,"13600000412", "778896"); printf("%d",sock); if (sock < 1) { printf("fail to connect to the server. Error Numbers is %d\n", sock); system("Pause"); return 1; } res = MongateCsGetSmsEx(sock, buf); printf ("sms %d %s\n", res,buf); res = MongateCsSendSms(sock, "15986756631", "Hello, world!", 1, buf); if ( res == 1) printf("Send success.SN is %s\n", buf); else printf("Send failed. Error Numbers is %d\n", res); res = MongateCsGetSms(sock, msg); if (res == 0) { puts("There is 0 new sms."); } else { for (i = 0; i < res; ++i) { printf("(%d): %s\n", i+1, msg[i]); } } MongateDisconnect(sock); return 0; }
CString CXKUsername::Realusername() { time_t m_time; //得到系统时间,从1970.01.01.00:00:00 开始的秒数 long m_time1c; //时间初处理m_time1c为结果,经过时间计算出的第一次加密 long m_time1convert; //对时间操作后的结果,此为格式字串的原始数据 unsigned char ss[4] = { 0,0,0,0 }; //源数据1,对m_time1convert进行计算得到格式符源数据 unsigned char ss2[4] = { 0,0,0,0 }; //md5加密参数的一部分,m_time1c的字符形式 CString strS1; //md5加密参数的一部分,ss2的整体形式 CString m_formatsring; //由m_timece算出的字符串,一般为可视字符 CString m_md5; //对初加密(m_timec字符串表示+m_username+radius)的MD5加密 CString m_md5use; //md5 Lower模式的前两位 //取得系统时间m_time time(&m_time); //时间初处理m_time1c为结果,经过时间计算出的第一次加密 //子函数//////////////////////////// { LONG64 t; t = m_time; t *= 0x66666667; t >>= 0x20; t >>= 0x01; m_time1c = (long) t; } //5秒内动态用户名一致处理 if (m_time1c <= m_lasttimec) { m_time1c = m_lasttimec + 1; } m_lasttimec = m_time1c; { long t; t = m_time1c; ss2[3] = (t & 0xFF); ss2[2] = (t & 0xFF00) / 0x100 ; ss2[1] = (t & 0xFF0000) / 0x10000; ss2[0] = (t & 0xFF000000) / 0x1000000; { //strS1必须用自加得到,真接加出问题 for (int i = 0; i < 4; i++) { strS1 += ss2[i]; } } } ///////////////////////////////////// //倒置过程m_time1convert为结果 //子函数//////////////////////////// { int t, t1, t2, t3; t = m_time1c; t1 = t; t2 = t; t3 = t; t3 = t3 << 0x10; t1 = t1 & 0x0FF00; t1 = t1 | t3; t3 = t; t3 = t3 & 0x0FF0000; t2 = t2 >> 0x10; t3 = t3 | t2; t1 = t1 << 0x08; t3 = t3 >> 0x08; t1 = t1 | t3; m_time1convert = t1; } ///////////////////////////////////// //源数据1,对m_time1convert进行计算得到格式符源数据 //子函数//////////////////////////// { long t; t = m_time1convert; ss[3] = (t & 0xFF); ss[2] = (t & 0xFF00) / 0x100 ; ss[1] = (t & 0xFF0000) / 0x10000; ss[0] = (t & 0xFF000000) / 0x1000000; } ///////////////////////////////////// //格式符初加密 unsigned char pp[4] = { 0,0,0,0 }; //子函数//////////////////////////// { int i = 0, j = 0, k = 0; for (i = 0; i < 0x20; i++) { j = i / 0x8; k = 3 - (i % 0x4); pp[k] *= 0x2; if (ss[j] % 2 == 1) { pp[k]++; } ss[j] /= 2; } } ///////////////////////////////////// //格式符计算,m_formatsring为结果 unsigned char pf[6] = { 0,0,0,0,0,0 }; //子函数//////////////////////////// { if(sizeof(int)==2){ int t1, t2; t1 = pp[3]; t1 /= 0x4; pf[0] = t1; t1 = pp[3]; t1 = t1 & 0x3; t1 *= 0x10; pf[1] = t1; t2 = pp[2]; t2 /= 0x10; t2 = t2 | t1; pf[1] = t2; t1 = pp[2]; t1 = t1 & 0x0F; t1 *= 0x04; pf[2] = t1; t2 = pp[1]; t2 /= 0x40; t2 = t2 | t1; pf[2] = t2; t1 = pp[1]; t1 = t1 & 0x3F; pf[3] = t1; t2 = pp[0]; t2 /= 0x04; pf[4] = t2; t1 = pp[0]; t1 = t1 & 0x03; t1 *= 0x10; pf[5] = t1; } else{ short t1,t2 ; t1 = pp[3]; t1 /= 0x4; pf[0] = t1; t1 = pp[3]; t1 = t1 & 0x3; t1 *= 0x10; pf[1] = t1; t2 = pp[2]; t2 /= 0x10; t2 = t2 | t1; pf[1] = t2; t1 = pp[2]; t1 = t1 & 0x0F; t1 *= 0x04; pf[2] = t1; t2 = pp[1]; t2 /= 0x40; t2 = t2 | t1; pf[2] = t2; t1 = pp[1]; t1 = t1 & 0x3F; pf[3] = t1; t2 = pp[0]; t2 /= 0x04; pf[4] = t2; t1 = pp[0]; t1 = t1 & 0x03; t1 *= 0x10; pf[5] = t1; } } ///////////////////////////////////// { int i; for (i = 0; i < 6; i++) { pf[i] += 0x20; if ((pf[i]) >= 0x40) { pf[i]++; } } } { for (int i = 0; i < 6; i++) { m_formatsring += pf[i]; } } ///////////////////////////////////// CString strInput; char temp[100]; unsigned lenth = 0; strInput = strS1 + m_username.Left(m_username.FindOneOf("@")) + RADIUS; lenth = 20 + m_username.FindOneOf("@"); memcpy(temp, strInput.c_str(), 100); // strcpy(temp,strInput.c_str()); m_md5 = MD5String(temp, lenth); m_md5use = m_md5.Left(2); m_realusername = m_formatsring + m_md5use + m_username; m_realusername = LR + m_realusername;//前面两位为回车换行0D0A,接着再是后续的 //#define _debug #ifdef _debug cout<<"m_username.FindOneOf(\"@\"):"<<m_username.FindOneOf("@")<<endl; cout<<"sizeof(int):"<<sizeof(int)<<",m_formatsring:"<<m_formatsring<<endl<<"temp:"<<temp<<",m_md5:"<<m_md5<<endl<<"m_realusername:"******", m_md5use:"<< m_md5use<<endl; #endif return m_realusername; }
int #else bool #endif tic_Login(struct TIC_conf *tic, const char *username, const char *password, const char *server) { char buf[1024], sSignature[33], sChallenge[1024]; int i; #ifndef _WIN32 struct utsname uts_name; #else OSVERSIONINFO osv; OSVERSIONINFOEX osvEx; char *platform = NULL; char version[100]; #endif D(dolog(LOG_DEBUG, "Trying to connect to TIC server %s\n", server)); /* Connect to the TIC server */ tic->sock = connect_client(server, TIC_PORT, AF_INET, SOCK_STREAM); if (!tic->sock) { dolog(LOG_ERR, "Couldn't connect to the TIC server %s\n", server); return false; } /* Fetch the welcome */ if (sock_getline(tic->sock, tic_buf, sizeof(tic_buf), &tic_filled, buf, sizeof(buf)) == -1) { return false; } if (buf[0] != '2') { dolog(LOG_ERR, "TIC Server is currently not available\n"); #ifdef AICCU_PATCH return TKZAiccuErrNoTicConnection; //error tic server is not available #else return false; #endif } /* Send our client identification */ #ifndef _WIN32 uname(&uts_name); sock_printf(tic->sock, "client TIC/%s %s/%s %s/%s\n", TIC_VERSION, TIC_CLIENT_NAME, TIC_CLIENT_VERSION, uts_name.sysname, uts_name.release); #else osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); osvEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); if (!GetVersionEx(&osv)) { platform = "Windows"; snprintf(version, sizeof(version), "%s", "Unknown"); } else { platform = (osv.dwPlatformId == VER_PLATFORM_WIN32s) ? "Win32s" : ((osv.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) ? "Win9x" : ((osv.dwPlatformId == VER_PLATFORM_WIN32_NT) ? "WinNT" : "Windows")); if ( osv.dwMajorVersion < 5 || !GetVersionEx((OSVERSIONINFO *)&osvEx) || osvEx.wServicePackMajor <= 0) { snprintf(version, sizeof(version), "%d.%d.%d", osv.dwMajorVersion, osv.dwMinorVersion, osv.dwBuildNumber); } else if (osvEx.wServicePackMinor <= 0) { snprintf(version, sizeof(version), "%d.%d.%d-SP%d", osv.dwMajorVersion, osv.dwMinorVersion, osv.dwBuildNumber, osvEx.wServicePackMajor); } else { snprintf(version, sizeof(version), "%d.%d.%d-SP%d.%d", osv.dwMajorVersion, osv.dwMinorVersion, osv.dwBuildNumber, osvEx.wServicePackMajor, osvEx.wServicePackMinor); } } sock_printf(tic->sock, "client TIC/%s %s/%s %s/%s\n", TIC_VERSION, TIC_CLIENT_NAME, TIC_CLIENT_VERSION, platform, version); #endif /* Fetch the answer */ if (sock_getline(tic->sock, tic_buf, sizeof(tic_buf), &tic_filled, buf, sizeof(buf)) == -1) { return false; } if (buf[0] != '2') { dolog(LOG_ERR, "Couldn't pass client information: %s.\n", &buf[4]); #ifdef AICCU_PATCH return TKZAiccuErrClientNotUpToDate; //error, client ist not up-to-date #else return false; #endif } /* Request current time */ sock_printf(tic->sock, "get unixtime\n"); /* Fetch the answer */ if (sock_getline(tic->sock, tic_buf, sizeof(tic_buf), &tic_filled, buf, sizeof(buf)) == -1) { return false; } if (buf[0] != '2') { dolog(LOG_ERR, "Time not available? %s\n", &buf[4]); return false; } /* Check if the time is correct */ i = tic_checktime(atoi(&buf[4])); if (i != 0) { char quitmsg[100]; dolog(LOG_ERR, "The clock is off by %d seconds, use NTP to sync it!\n", i); snprintf(quitmsg, sizeof(quitmsg), "Aborting: Clock is off by %d seconds\n", i); tic_Logout(tic, quitmsg); #ifdef AICCU_PATCH return TKZAiccuErrNoTimeSync; #else return false; #endif } #ifdef AICCU_GNUTLS /* Upgrade to TLS */ sock_printf(tic->sock, "starttls\n"); /* Fetch the welcome */ if (sock_getline(tic->sock, tic_buf, sizeof(tic_buf), &tic_filled, buf, sizeof(buf)) == -1) { return false; } if (buf[0] == '2') { /* Go to TLS mode */ if (!sock_gotls(tic->sock)) return false; } else { if (g_aiccu->requiretls) { dolog(LOG_ERR, "TIC Server does not support TLS and TLS is required\n"); return false; } if (g_aiccu->verbose) dolog(LOG_WARNING, "TIC Server does not support TLS but TLS is not required, continuing\n"); } #endif /* Send our username */ sock_printf(tic->sock, "username %s\n", username); /* Fetch the answer */ if (sock_getline(tic->sock, tic_buf, sizeof(tic_buf), &tic_filled, buf, sizeof(buf)) == -1) { return false; } if (buf[0] != '2') { dolog(LOG_ERR, "Username not accepted: %s.\n", &buf[4]); #ifdef AICCU_PATCH return TKZAiccuErrInvalidUser; // error, invalid username #else return false; #endif } /* Pick a challenge */ sock_printf(tic->sock, "challenge md5\n"); /* Fetch the answer */ if (sock_getline(tic->sock, tic_buf, sizeof(tic_buf), &tic_filled, buf, sizeof(buf)) == -1) { return false; } if (buf[0] != '2') { dolog(LOG_ERR, "Challenge not correct: %s.\n", &buf[4]); return false; } /* Send the response */ /* sSignature = md5(challenge.md5(password)); */ MD5String(password, sSignature, sizeof(sSignature)); snprintf(sChallenge, sizeof(sChallenge), "%s%s", &buf[4], sSignature); MD5String(sChallenge, sSignature, sizeof(sSignature)); sock_printf(tic->sock, "authenticate md5 %s\n", sSignature); /* Fetch the answer */ if (sock_getline(tic->sock, tic_buf, sizeof(tic_buf), &tic_filled, buf, sizeof(buf)) == -1) { tic_Logout(tic, NULL); return false; } if (buf[0] != '2') { tic_Logout(tic, NULL); dolog(LOG_ERR, "Response not accepted: %s.\n", &buf[4]); #ifdef AICCU_PATCH return TKZAiccuErrInvalidPwd; // error, password not correct #else return false; #endif } /* Connect OK */ return true; }
int main() { printf("libmd version %s, built at " __TIME__ ", " __DATE__ ".\n", libmd_version); printf ("---------- MD2 TEST SUITE ----------\n"); MD2String ("", "\"\"", "8350e5a3e24c153df2275c9f80692773"); MD2String ("a", "\"a\"", "32ec01ec4a6dac72c0ab96fb34c0b5d1"); MD2String ("abc", "\"abc\"", "da853b0d3f88d99b30283a69e6ded6bb"); MD2String ("message digest","\"message digest\"", "ab4f496bfb2a530b219ff33031fe06b0"); MD2String ("abcdefghijklmnopqrstuvwxyz","a..z", "4e8ddff3650292ab5a4108c3aa47940b"); MD2String ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "A..Za..z0..9","da33def2a42df13975352846c30338cd"); MD2String ("123456789012345678901234567890123456789" "01234567890123456789012345678901234567890", "8 times \"1234567890\"","d5976f79d83d3a0dc9806c3c66f3efd8"); MD2TimeTrial(); printf ("---------- MD4 TEST SUITE ----------\n"); MD4String ("", "\"\"", "31d6cfe0d16ae931b73c59d7e0c089c0"); MD4String ("a", "\"a\"", "bde52cb31de33e46245e05fbdbd6fb24"); MD4String ("abc", "\"abc\"", "a448017aaf21d8525fc10ae87aa6729d"); MD4String ("message digest","\"message digest\"", "d9130a8164549fe818874806e1c7014b"); MD4String ("abcdefghijklmnopqrstuvwxyz","a..z", "d79e1c308aa5bbcdeea8ed63df412da9"); MD4String ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "A..Za..z0..9","043f8582f241db351ce627e153e7f0e4"); MD4String ("123456789012345678901234567890123456789" "01234567890123456789012345678901234567890", "8 times \"1234567890\"","e33b4ddc9c38f2199c3e7b164fcc0536"); MD4TimeTrial(); printf ("---------- MD5 TEST SUITE ----------\n"); MD5String ("", "\"\"", "d41d8cd98f00b204e9800998ecf8427e"); MD5String ("a", "\"a\"", "0cc175b9c0f1b6a831c399e269772661"); MD5String ("abc", "\"abc\"", "900150983cd24fb0d6963f7d28e17f72"); MD5String ("message digest","\"message digest\"", "f96b697d7cb7938d525a2f31aaf161d0"); MD5String ("abcdefghijklmnopqrstuvwxyz","a..z", "c3fcd3d76192e4007dfb496cca67e13b"); MD5String ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "A..Za..z0..9","d174ab98d277d9f5a5611c2c9f419d9f"); MD5String ("123456789012345678901234567890123456789" "01234567890123456789012345678901234567890", "8 times \"1234567890\"","57edf4a22be3c955ac49da2e2107b67a"); MD5TimeTrial(); printf ("---------- RIPEMD-160 TEST SUITE ----------\n"); RMD160String ("", "\"\"", "9c1185a5c5e9fc54612808977ee8f548b2258d31"); RMD160String ("a", "\"a\"", "0bdc9d2d256b3ee9daae347be6f4dc835a467ffe"); RMD160String ("abc", "\"abc\"", "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc"); RMD160String ("message digest","\"message digest\"", "5d0689ef49d2fae572b881b123a85ffa21595f36"); RMD160String ("abcdefghijklmnopqrstuvwxyz","a..z", "f71c27109c692c1b56bbdceb5b9d2865b3708dbc"); RMD160String ("ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz0123456789", "A..Za..z0..9","b0e20b6e3116640286ed3a87a5713079b21f5189"); RMD160String ("123456789012345678901234567890123456789" "01234567890123456789012345678901234567890", "8 times \"1234567890\"", "9b752e45573d4b39f4dbd3323cab82bf63326bfb"); RMD160TimeTrial(); printf ("---------- SHA-1 TEST SUITE ----------\n"); SHAString ("", "\"\"", "da39a3ee5e6b4b0d3255bfef95601890afd80709"); SHAString ("a", "\"a\"", "86f7e437faa5a7fce15d1ddcb9eaeaea377667b8"); SHAString ("abc", "\"abc\"", "a9993e364706816aba3e25717850c26c9cd0d89d"); SHAString ("message digest","\"message digest\"", "c12252ceda8be8994d5fa0290a47231c1d16aae3"); SHAString ("abcdefghijklmnopqrstuvwxyz","a..z", "32d10c7b8cf96570ca04ce37f2a19d84240d3a89"); SHAString ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "A..Za..z0..9","761c457bf73b14d27e9e9265c46f4b4dda11f940"); SHAString ("123456789012345678901234567890123456789" "01234567890123456789012345678901234567890", "8 times \"1234567890\"", "50abf5706a150990a08b2c5ea40fa0e585554732"); SHATimeTrial(); exit(MDFailed); /* Solaris bug... */ return MDFailed; }
int main() { base::AtExitManager exit_manager; base::CommandLine::Init(0, NULL); BaseInitLoggingImpl(L"debug.log", base::LOG_ONLY_TO_FILE, base::LOCK_LOG_FILE, base::DELETE_OLD_LOG_FILE); int loga = base::Log2Floor(1); base::Environment* e = base::Environment::Create(); std::string sys_path; e->GetVar("path", &sys_path); base::CPU cpu; bool finite = base::IsFinite(1.01); base::FilePath path; std::vector<std::wstring> components; path.GetComponents(&components); path.Append(L"c:"); path.Append(L"pWRD"); path.Append(L"testDir"); path.Append(L"\\wlw.txt"); path.GetComponents(&components); bool absolute = path.IsAbsolute(); base::FilePath path2(L"wlwtxt"); path2.GetComponents(&components); absolute = path2.IsAbsolute(); base::FilePath search_path(L"C:\\"); base::CountFilesCreatedAfter(search_path, base::Time::Now()); int err = base::EnsureDirectoryForFile(path, NULL); base::Delete(base::FilePath(L"c:\\pWRD"), true); FileVersionInfo* fvi = FileVersionInfo::CreateFileVersionInfoForCurrentModule(); if(fvi) { std::wstring file_ver = fvi->file_version(); delete fvi; } base::FileEnumerator file_iter(search_path, false, base::FileEnumerator::DIRECTORIES, L"3rd"); for(base::FilePath current=file_iter.Next(); !current.Empty(); current=file_iter.Next()) { std::wcout << current.value() << std::endl; base::FileEnumerator::FindInfo fi; file_iter.GetFindInfo(&fi); if(file_iter.IsDirectory(fi)) { int64 size = base::ComputeDirectorySize(current); std::wcout << L"Directory size is: " << size << std::endl; size = base::ComputeFilesSize(current, L""); std::wcout << L"Files size is: " << size << std::endl; } } Pickle p; p.WriteInt(1); p.WriteString("I'm wlw!"); p.WriteWString(L"I'm WLW!"); int p_i; std::string p_str; std::wstring p_wstr; void* iter = NULL; p.ReadInt(&iter, &p_i); p.ReadString(&iter, &p_str); p.ReadWString(&iter, &p_wstr); base::RegKey reg(HKEY_CURRENT_USER, L"Environment", KEY_QUERY_VALUE); std::wstring reg_temp; if(reg.Valid()) { reg.ReadValue(L"TEMP", ®_temp); } CoInitialize(NULL); base::ScopedComPtr<IDropTargetHelper, &IID_IDropTargetHelper> scomp; if(SUCCEEDED(scomp.CreateInstance(CLSID_DragDropHelper))) { scomp = NULL; } CoUninitialize(); scoped_ptr<double> spd(new double(3.1)); spd.reset(); base::Singleton<FooClass>::get()->Bar(); int cvt = 0; base::StringToInt("123", &cvt); std::string str_d = base::DoubleToString(2.123); base::StringPiece s1; assert(s1.length() == 0); assert(s1.size() == 0); assert(s1.data() == NULL); base::StringPiece s2("I love you"); assert(s2.find('I') != base::StringPiece::npos); std::vector<std::string> v; base::SplitString("wlw&el", '&', &v); std::vector<std::string> subst; subst.push_back("10"); subst.push_back("20"); subst.push_back("30"); std::string add = ReplaceStringPlaceholders("$2+$1=$3", subst, NULL); string16 bytes = FormatBytes(5*1024, DATA_UNITS_KIBIBYTE, true); std::string profile = base::StringPrintf("wlw's age is %d", 29); LOG(WARNING) << "This is a warning!"; //DCHECK(1 == 0); base::Time::EnableHighResolutionTimer(true); base::Time t = base::Time::Now(); base::Time::Exploded te; t.LocalExplode(&te); base::TimeTicks tt = base::TimeTicks::Now(); base::TimeTicks tth = base::TimeTicks::HighResNow(); std::string utf8 = WideToUTF8(L"wan lian wen - мРа╛нд"); std::wstring wide = UTF8ToWide(utf8); DictionaryValue root; root.SetString("global.pages.homepage", "http://goateleporter.com"); std::string homepage = "http://google.com"; root.GetString("global.pages.homepage", &homepage); Version* ver = Version::GetVersionFromString("2.0.0.1"); delete ver; base::WinVersion version = base::GetWinVersion(); std::wstring user_sid; base::GetUserSidString(&user_sid); std::string base64; base::Base64Encode("I'm wlw.", &base64); std::string md5 = MD5String("I'm wlw."); std::string sha1 = base::SHA1HashString("I'm wlw."); std::string sha2 = base::SHA256HashString("I'm wlw."); std::string json = base::GetDoubleQuotedJson("a<>b;\nb = 0;"); std::string json_write; base::JSONWriter::Write(&root, false, &json_write); Value* json_read = base::JSONReader::Read(json_write, false); delete json_read; Tuple3<int, double, bool> t3 = MakeTuple(10, 2.5, false); ObjClass obj; Callback0::Type* callback = NewCallback(&obj, &ObjClass::Bar); callback->Run(); delete callback; thred.Start(); thred.message_loop()->PostDelayedTask(new PrintTask(), 1000); MessageLoop msg_loop; msg_loop.PostDelayedTask(new MainThreadPrintTask(), 3000); msg_loop.Run(); thred.Stop(); return 0; }
int md_check (cfg_t * cfg) { time_t now; int len = 0; int i; int cnt; int net_pos[5]; char netrom[6]; char temp[256]; char buf[256]; char hostname[128]; /* char md2str[33]; */ char md5str[33]; time (&now); len = strlen (cfg->password); srandom(time(NULL)); for (i = 0; i < 5; i++) { net_pos[i] = (random () % len); netrom[i] = cfg->password[net_pos[i]]; } netrom[i] = '\0'; gethostname (hostname, sizeof (hostname)); /*limit hostname to 20 characters */ hostname[20] = '\0'; sprintf (temp, "%s> %d %d %d %d %d [%010ld]\n", hostname, net_pos[0] + 1, net_pos[1] + 1, net_pos[2] + 1, net_pos[3] + 1, net_pos[4] + 1, now); write_ax25 (temp, strlen (temp)); sprintf (temp, "%010d%s", (int) now, cfg->password); /* MD2String (md2str, temp); */ MD5String (md5str, temp); cnt = read_ax25 (buf, sizeof (buf)); if (cnt < 0) /* Connection died */ { return 0; } buf[cnt] = '\0'; for (i = 0; buf[i]; ++i) { if (buf[i] < ' ') { buf[i] = '\0'; break; } } if (*buf) { /* Plain text */ if (!strcasecmp (buf, cfg->password)) return 1; /* NetRom */ if (!strcasecmp (buf, netrom)) return 1; /* MD5 */ if (!strcasecmp (buf, md5str)) return 1; /* MD2 */ /* if (!strcasecmp (buf, md2str)) return 1; */ } return 0; }
std::string MD5String(std::string string) { return MD5String(1, string); }