示例#1
1
std::string Hash(const std::string& data) {
    // todo: use some other hash algoritm
    CryptoPP::MD5 hash;
    std::string result;
    result.resize(CryptoPP::MD5::DIGESTSIZE);
    hash.CalculateDigest((byte*)result.data(), (byte*)data.data(), data.length());
    return result;
}
示例#2
0
        //Hash data by MD5 algorhitm
        inline std::string MD5(const std::string& data)
        {
                std::string res;
                CryptoPP::MD5 hash;
                byte digest[CryptoPP::MD5::DIGESTSIZE];

                hash.CalculateDigest(digest, (byte*)data.c_str(), data.size());

                CryptoPP::HexEncoder encoder;
                encoder.Attach(new CryptoPP::StringSink(res));
                encoder.Put(digest, sizeof(digest));
                encoder.MessageEnd();

                return res;
        }
示例#3
0
void CLoginDlg::OnBnClickedOk()
{
	// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
	CComm func;

	//환경파일 저장되는지 확인.
	CString plainTxt;

	m_cID.GetWindowText(m_strID);
	m_cPwd.GetWindowText(plainTxt);

#ifdef _HTTPS	
	CryptoPP::MD5 hash;
	byte digest[CryptoPP::MD5::DIGESTSIZE];
	std::string message = func.Convert2string(plainTxt);

	hash.CalculateDigest(digest, (byte*)message.c_str(), message.length());

	CryptoPP::HexEncoder encoder;
	std::string output;
	encoder.Attach(new CryptoPP::StringSink(output));
	encoder.Put(digest, sizeof(digest));
	encoder.MessageEnd();
	//std::cout << output << std::endl;

	m_strPWD = output.c_str();
	m_strPWD.MakeLower();
	//OutputDebugString(m_strPWD);
#else
	m_strPWD = plainTxt;
#endif


	CString strFormData = L"";
	strFormData.Format(_T("email=%s&password=%s"), m_strID, m_strPWD);

	//로그인
	DWORD dwRtn = login(SRV_URL, LGN_API, strFormData);

	if (dwRtn == HTTP_STATUS_FORBIDDEN){
		MessageBox(L"ID or Password Error!");
		m_cID.SetWindowText(L"");
		m_cPwd.SetWindowText(L"");
		m_cID.SetFocus();
		return;
	}else if (dwRtn == HTTP_STATUS_DENIED){
		//토큰 Expire
		AfxMessageBox(L"Token Expire or Not found!");
		return;
	}
	else if (dwRtn != HTTP_STATUS_OK){
		MessageBox(L"Login Fail");
		m_cID.SetWindowText(L"");
		m_cPwd.SetWindowText(L"");
		m_cID.SetFocus();
		return;
	}


	//사용자 프로파일 취득.
	// 성공일 경우 사용자 프로파일 취득.
	dwRtn = userProfile(SRV_URL, PROFILE);

	if (dwRtn != HTTP_STATUS_OK){
		AfxMessageBox(L"Get User Profile Fail");
		return;
	}

	CDialogEx::OnOK();
}
示例#4
0
byte * get_checksum(unsigned char * msg) {
    CryptoPP::MD5 hash;
    byte * digest = (byte *) malloc(CryptoPP::MD5::DIGESTSIZE * sizeof(byte));
    hash.CalculateDigest(digest, msg, 208);
    return digest;
}