Changeset 33 in chevmsgr
- Timestamp:
- 12/09/15 06:47:21 (8 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/msg.hpp
r31 r33 175 175 static cf::bin generateRandom() 176 176 { 177 int t = (int)time(NULL); 177 srand((unsigned int)time(NULL)); 178 int t = rand(); 178 179 179 180 cf::bin b; -
trunk/msgclnt.cpp
r32 r33 89 89 SOpenSession o; 90 90 91 o.sessid = message.get<std::string>(ProtocolType::SESSION_ID);92 o.idList = message.getList<std::string>(ProtocolType::ID_LIST);93 94 91 if (message.mObject.HasKey(ProtocolType::SESSION_KEY)) 95 92 { 93 o.sessid = message.get<std::string>(ProtocolType::SESSION_ID); 94 o.idList = message.getList<std::string>(ProtocolType::ID_LIST); 95 96 96 std::string encodedKey = message.get<std::string>(ProtocolType::SESSION_KEY); 97 97 cf::bin key = cf::codec::hex::getInstance()->decode(encodedKey); -
trunk/msgsrv.cpp
r31 r33 294 294 } 295 295 296 static unsigned int generateSeed()297 {298 unsigned int ret = 0;299 int t = (int)time(NULL);300 301 cf::bin b;302 b.resize(sizeof(int));303 304 b.set((cf::uint8_t*)&t, sizeof(int));305 cf::bin s = crypto().sha256(b);306 307 memcpy(&ret, s.buffer(), sizeof(unsigned int));308 309 return ret;310 }311 312 296 static std::string generateSMSCode() 313 297 { 314 return "545454"; 315 char random[8] = {0x00,}; 316 sprintf(random, "%06d", generateSeed() % 1000000); 317 318 return random; 298 cf::bin random = generateRandom(); // ·£´ý °ª °¡Á®¿È 299 cf::bin hash = crypto().sha256(random); // ·£´ý °ª Çؽ¬ 300 std::string enc = cf::codec::hex::getInstance()->encode(hash); // Çؽ¬ÇÑ °á°ú hex encode 301 302 std::string sms; // ÃÖÁ¾ sms¹ÞÀ» º¯¼ö 303 304 // xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx 305 for (int i = 0; i < 8 ; i++) 306 { 307 char buf[128] = {0,}; 308 309 // [0] ºÎÅÍ 4±ÛÀÚ, [4] ºÎÅÍ 4±ÛÀÚ, ... 310 size_t start = i * 4; 311 312 // 1. enc º¯¼ö¿¡¼ 4ÀÚ¸®¾¿ ¼ø¼´ë·Î ¶¼¾î³»¼ xxxx- ·Î ¸¸µë 313 // std::string::substr(½ÃÀÛ À妽º, °³¼ö) 314 // 2. std::string::substr() ´Â std::stringÀ» return ÇϹǷÎ, 315 // std::string::c_str() ÇÏ¿© const char * ÇüÀ¸·Î ¹Þ¾Æ¿È 316 snprintf(buf, sizeof(buf), "%s-", enc.substr(start, 4).c_str()); 317 318 // xxxx- ·Î ¸¸µç°Å sms °á°ú¿¡ Ãß°¡ 319 sms += buf; 320 } 321 322 // ·çÇÁ¿¡¼ xxxx- ¸¦ °è¼Ó ºÙ¿©¼ ´Ù ¸¸µé°í ³ª¸é ¸¶Áö¸·ÀÌ '-' ·Î ³¡³ª°Ô µÇ¹Ç·Î ¸¶Áö¸· ±ÛÀÚ ¶¼¾î³¿ 323 sms[sms.length() - 1] = 0; 324 325 return sms; 319 326 } 320 327 … … 325 332 #define CRLF "\r\n" 326 333 std::string code = generateSMSCode(); 327 std::string url = " unsigned.kr";328 std::string uri = "/ ~cheese/sms/req.php?to=" + phone + "&code=" + code;334 std::string url = "chev.unsigned.kr"; 335 std::string uri = "/sms/req.php?to=" + phone + "&code=" + code; 329 336 std::string http = 330 337 "GET " + uri + " HTTP/1.1" CRLF -
trunk/msvc14/ChevMsgrClient_MFC/AddGroupChat.cpp
r30 r33 41 41 42 42 for (size_t iter = 0; iter < mMsgrClntDlg->idList.size(); iter++) 43 mFriendListToChat.InsertString( iter, str2cstr(mMsgrClntDlg->idList[iter].id));43 mFriendListToChat.InsertString((int)iter, str2cstr(mMsgrClntDlg->idList[iter].id)); 44 44 45 45 return TRUE; -
trunk/msvc14/ChevMsgrClient_MFC/ChevMsgrClient_MFCDlg.cpp
r32 r33 136 136 { 137 137 AfxMessageBox(_T("¼¹ö Á¤º¸ ÆÄÀÏÀ» ãÀ» ¼ö ¾øÀ½")); 138 ::SendMessage(GetSafeHwnd(), WM_QUIT, NULL, NULL);138 exit(1); 139 139 } 140 140 std::string ip; … … 147 147 { 148 148 AfxMessageBox(str2cstr(chev.getLastError())); 149 ::SendMessage(GetSafeHwnd(), WM_QUIT, NULL, NULL);149 exit(1); 150 150 } 151 151 … … 155 155 { 156 156 AfxMessageBox(_T("login failed")); 157 ::SendMessage(GetSafeHwnd(), WM_QUIT, NULL, NULL);157 exit(1); 158 158 } 159 159 … … 243 243 SensitiveCtrl sc; 244 244 245 sc.sensitiveIdx = gDlg->scl[idx].chatList.size();245 sc.sensitiveIdx = (int)gDlg->scl[idx].chatList.size(); 246 246 sc.timestamp = (int)time(NULL); 247 247 gDlg->scl[idx].sensitiveCtrl.push_back(sc); … … 341 341 SensitiveCtrl sc; 342 342 343 sc.sensitiveIdx = gDlg->scl[idx].chatList.size();343 sc.sensitiveIdx = (int)gDlg->scl[idx].chatList.size(); 344 344 sc.timestamp = (int)time(NULL); 345 345 gDlg->scl[idx].sensitiveCtrl.push_back(sc); -
trunk/msvc14/ChevMsgrClient_MFC/LoginDlg.cpp
r31 r33 59 59 60 60 GetDlgItemText(IDC_EDIT_LOGIN_ID, id); 61 if (id == _T("")) 62 { 63 AfxMessageBox(_T("No ID")); 64 return; 65 } 66 61 67 std::string name = cf::codec::hex::getInstance()->encode(c.sha256(cf::bin(cstr2str(id)))); 62 68 std::ifstream f(name); … … 70 76 71 77 GetDlgItemText(IDC_EDIT_LOGIN_PW, pw); 78 if (pw == _T("")) 79 { 80 AfxMessageBox(_T("No Password")); 81 return; 82 } 83 72 84 f >> str; 73 85
Note:
See TracChangeset
for help on using the changeset viewer.