diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp index ee3fe6d..445a6f1 100644 --- a/src/chatmodel.cpp +++ b/src/chatmodel.cpp @@ -374,7 +374,236 @@ Tx MainWindow::createTxFromChatPage() { QString hmemo= createHeaderMemo(type,cid,myAddr); - QString memo = ui->memoTxtChat->toPlainText().trimmed(); + QString memounencrypt = ui->memoTxtChat->toPlainText().trimmed(); + + + int length = memounencrypt.length(); + + char *sequence = NULL; + sequence = new char[length+1]; + strncpy(sequence, memounencrypt.toLocal8Bit(), length +1); + +////////////////////////////////////////////////////Important: If we can decrypt the output of QString memo, after we encrypt it, Bobs code must be in Controller.cpp + + /////////////////Alice Pubkey + #define MESSAGEAP ((const unsigned char *) "Ioesd") + #define MESSAGEAP_LEN 5 + + unsigned char alice_publickey[crypto_secretstream_xchacha20poly1305_KEYBYTES]; + + crypto_generichash(alice_publickey, sizeof alice_publickey, + MESSAGEAP, MESSAGEAP_LEN, + NULL, 0); + QString alice = QString::fromLocal8Bit((char*)alice_publickey); + qDebug()<<"Alice Pubkey : "<(c1), CIPHERTEXT_LEN); + + qDebug()<<"Size Controller Memo :"<< encryptedMemo.length(); + + QString memo = QString::fromUtf8( encryptedMemo.data(), encryptedMemo.size()); + + + /////////////////Bob Pubkey + #define MESSAGEBAP1 ((const unsigned char *) "Hal12") + #define MESSAGEBAP1_LEN 5 + + unsigned char bob1_publickey[crypto_secretstream_xchacha20poly1305_KEYBYTES]; + + crypto_generichash(bob1_publickey, sizeof bob1_publickey, + MESSAGEBAP1, MESSAGEBAP1_LEN, + NULL, 0); + + qDebug()<<"Bobs Pubkey created"; + + /////////////////Bob Secretkey + #define MESSAGEBS ((const unsigned char *) "Hal11") + #define MESSAGEBS_LEN 5 + + unsigned char bob_secretkey[crypto_secretstream_xchacha20poly1305_HEADERBYTES]; + + crypto_generichash(bob_secretkey, sizeof bob_secretkey, + MESSAGEBS, MESSAGEBS_LEN, + NULL, 0); + + qDebug()<<"Bobs Pubkey created"; + + /////////////////Alice Pubkey bob creates + #define MESSAGEA121 ((const unsigned char *) "Ioesd") + #define MESSAGEAP121_LEN 5 + + unsigned char alice1_publickey[crypto_secretstream_xchacha20poly1305_KEYBYTES]; + + crypto_generichash(alice1_publickey, sizeof alice1_publickey, + MESSAGEA121, MESSAGEAP121_LEN, + NULL, 0); + + QString alice1 = QString::fromLocal8Bit((char*)alice1_publickey); + qDebug()<<"Alice Pubkey Bob create: "<(m2),MESSAGE_LEN); + qDebug()<<"7: "; + QString memodecrypt = QString::fromUtf8( decryptedMemo.data(), decryptedMemo.size()); + + + + qDebug()<<"OUT decrypt:" << memodecrypt;