string SIPBuilder::_RegisterMd5( string username, string quato_realm, string passwd, string quato_uri, string quato_nonce) { string realm = quato_realm.substr(1, (quato_realm.length()-2)); string uri = quato_uri.substr(1, (quato_uri.length()-2)); string nonce = quato_nonce.substr(1, (quato_nonce.length()-2)); #ifdef DEBUG cout<<"username:"******"realm:"<<realm<<endl; cout<<"passwd:"<<passwd<<endl; cout<<"uri:"<<uri<<endl; cout<<"nonce:"<<nonce<<endl; #endif string rtresp_md5; MD5 md5; md5.update(username); md5.update(":"); md5.update(realm); md5.update(":"); md5.update(passwd); string hash1 = md5.toString(); MD5 md5_2; md5_2.update("REGISTER"); md5_2.update(":"); md5_2.update(uri); string hash3 = md5_2.toString(); MD5 md5_3; md5_3.update(hash1); md5_3.update(":"); string non( nonce); md5_3.update(non); md5_3.update(":"); md5_3.update(hash3); rtresp_md5 = md5_3.toString(); return rtresp_md5; }
/** * Simplifie une formule. * Cette fonction exprime les équivalences et implications de la formule en entrée avec les opérateurs ET, OU et NON. * Elle ramène également toutes les négations de la formule au niveau des littéraux. * @param form La formule à simplifier. * @param negation Indique si l'élément parent était un NON. Vaut false par défaut. * @return La formule simplifiée. * @see formule */ formule* simplifie_formule(const formule *form, const bool negation) { formule *form_out = NULL; switch(form->op) { case o_variable: { if(negation) { form_out = non(var(*(form->nom))); } else { form_out = var(*(form->nom)); } break; } case o_equivaut: { if(negation) { form_out = ou( et( simplifie_formule(form->arg1, true), simplifie_formule(form->arg2)), et( simplifie_formule(form->arg2, true), simplifie_formule(form->arg1)) ); } else { form_out = et( ou( simplifie_formule(form->arg1, true), simplifie_formule(form->arg2)), ou( simplifie_formule(form->arg2, true), simplifie_formule(form->arg1)) ); } break; } case o_implique: { if(negation) { form_out = et(simplifie_formule(form->arg1), simplifie_formule(form->arg2, true)); } else { form_out = ou(simplifie_formule(form->arg1, true), simplifie_formule(form->arg2)); } break; } case o_non: { form_out = simplifie_formule(form->arg, !negation); break; } case o_ou: { if(negation) { form_out = et(simplifie_formule(form->arg1, true), simplifie_formule(form->arg2, true)); } else { form_out = ou(simplifie_formule(form->arg1), simplifie_formule(form->arg2)); } break; } case o_et: { if(negation) { form_out = ou(simplifie_formule(form->arg1, true), simplifie_formule(form->arg2, true)); } else { form_out = et(simplifie_formule(form->arg1), simplifie_formule(form->arg2)); } break; } } return form_out; }