Audiovox P965 Datový list Strana 125

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 280
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 124
API In CPP
122
char cNull[1] = {0};
//Send login message
WriteWord("/login");
WriteWord(cNull);
ReadSentence(readSentence);
DEBUG ? readSentence.Print() : 0;
if (readSentence.GetReturnType() != DONE) {
printf("Error.\n");
} else {
// extract md5 string from the challenge sentence
char *strWord = new char [readSentence[1].size() + 1];
strcpy(strWord, readSentence[1].c_str());
char *md5Challenge = strtok(strWord, "=");
md5Challenge = strtok(NULL, "=");
DEBUG ? printf("MD5 of challenge = %s\n", md5Challenge) : 0;
////Place of interest: Check to see if this md5Challenge string works as as string.
// It may not because it needs to be binary.
// convert szMD5Challenge to binary
string md5ChallengeBinary = MD5ToBinary(md5Challenge);
delete[] strWord;
// get md5 of the password + challenge concatenation
md5_init(&state);
md5_append(&state, (const md5_byte_t *)cNull, 1);
md5_append(&state, (const md5_byte_t *)strPassword.c_str(),
strlen(strPassword.c_str()));
md5_append(&state, (const md5_byte_t *)md5ChallengeBinary.c_str(), 16);
md5_finish(&state, digest);
// convert this digest to a string representation of the hex values
// digest is the binary format of what we want to send
// szMD5PasswordToSend is the "string" hex format
string md5PasswordToSend = MD5DigestToHexString(digest);
DEBUG ? printf("MD5 Password To Send = %s\n", md5PasswordToSend.c_str()) : 0;
// put together the login sentence
writeSentence.AddWord("/login");
writeSentence.AddWord("=name=" + strUsername);
writeSentence.AddWord("=response=00" + md5PasswordToSend);
Zobrazit stránku 124
1 2 ... 120 121 122 123 124 125 126 127 128 129 130 ... 279 280

Komentáře k této Příručce

Žádné komentáře