diff --git a/CVerif_CB.cpp b/CVerif_CB.cpp new file mode 100644 index 0000000..4049f4f --- /dev/null +++ b/CVerif_CB.cpp @@ -0,0 +1,84 @@ +#include "CVerif_CB.h" +#include + +CVerif_CB::CVerif_CB() { +} + +CVerif_CB::~CVerif_CB() { +} + +bool CVerif_CB::getDateCB_OK() { + return dateCB_OK; +} + +bool CVerif_CB::getNumeroCB_OK() { + return numeroCB_OK; +} + +bool CVerif_CB::getCarteValide() { + return carteValide; +} + +void CVerif_CB::setCarteValide() { + if((getNumeroCB_OK() == true) && (getDateCB_OK() == true)) { + carteValide = true; + } + else { + carteValide = false; + } +} + +void CVerif_CB::VerifierNumeroCB(unsigned char *numerocb) { + for(int i=0; i<16; i++) { + numeroCB[i] = numerocb[i] - 0x30; + } + int somme = 0, reste = 0, index = 0, N1 = 0; + index = 1; + while(index <= 15) { + N1 = numeroCB[index]; + somme = somme + N1; + index = index + 2; + } + index = 0; + while(index <= 15) { + N1 = numeroCB[index]; + N1 = N1 * 2; + if(N1 > 9) { + N1 = N1 - 9; + } + somme = somme + N1; + index = index + 2; + } + reste = somme%10; + if(reste == 0) { + numeroCB_OK = true; + } + else { + numeroCB_OK = false; + } +} + +void CVerif_CB::VerifierDateCB(unsigned char moiscb, int anneecb) { + QDate DateJour = QDate::currentDate(); + if(moiscb < 13) { + if(DateJour.year() < anneecb) { + dateCB_OK = true; + } + else { + if(DateJour.year() <= anneecb) { + if(DateJour.month() <= moiscb) { + dateCB_OK = true; + } + else { + dateCB_OK = false; + } + } + else { + dateCB_OK = false; + } + } + } + else { + dateCB_OK = false; + } +} diff --git a/CVerif_CB.h b/CVerif_CB.h new file mode 100644 index 0000000..bee76b2 --- /dev/null +++ b/CVerif_CB.h @@ -0,0 +1,23 @@ +#ifndef CVERIF_CB_H +#define CVERIF_CB_H + +class CVerif_CB +{ +private: + unsigned char numeroCB[16]; + bool numeroCB_OK; + bool carteValide; + bool dateCB_OK; + +public: + CVerif_CB(); + ~CVerif_CB(); + void VerifierNumeroCB(unsigned char *numerocb); + void VerifierDateCB(unsigned char moiscb, int anneecb); + bool getNumeroCB_OK(); + bool getDateCB_OK(); + bool getCarteValide(); + void setCarteValide(); +}; + +#endif // CVERIF_CB_H diff --git a/CarteBancaire.pro b/CarteBancaire.pro new file mode 100644 index 0000000..c27ef84 --- /dev/null +++ b/CarteBancaire.pro @@ -0,0 +1,29 @@ +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +CONFIG += c++11 + +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + CVerif_CB.cpp \ + main.cpp \ + mainwindow.cpp + +HEADERS += \ + CVerif_CB.h \ + mainwindow.h + +FORMS += \ + mainwindow.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target + +RESOURCES += \ + image.qrc diff --git a/cb.png b/cb.png new file mode 100644 index 0000000..3cdd2ba Binary files /dev/null and b/cb.png differ diff --git a/image.qrc b/image.qrc new file mode 100644 index 0000000..e003720 --- /dev/null +++ b/image.qrc @@ -0,0 +1,6 @@ + + + cb.png + logo-cb.jpg + + diff --git a/logo-cb.jpg b/logo-cb.jpg new file mode 100644 index 0000000..b6e96a3 Binary files /dev/null and b/logo-cb.jpg differ diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..aff48df --- /dev/null +++ b/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" + +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + return a.exec(); +} diff --git a/mainwindow.cpp b/mainwindow.cpp new file mode 100644 index 0000000..e093a1f --- /dev/null +++ b/mainwindow.cpp @@ -0,0 +1,53 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" +#include + +using namespace std; + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + carteCB = new CVerif_CB(); + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::on_PB_Verifier_clicked() { + CVerif_CB verif; + int annee; + unsigned char mois; + unsigned char *numerocb = new unsigned char[16]; + char *numerocb2 = new char[16]; + strcpy(numerocb2, ui->LE_Numero->text().toLatin1()); + + for(int i=0; i<16; i++) { + numerocb[i] = numerocb2[i]; + } + + verif.VerifierNumeroCB(numerocb); + annee = ui->LE_Annee->text().toInt(); + mois = (unsigned char)ui->LE_Mois->text().toInt(); + verif.VerifierDateCB(mois,annee); + verif.setCarteValide(); + + if(verif.getCarteValide() == true) { + ui->label_Verification->setText("Valid card !"); + } + else { + if(verif.getNumeroCB_OK() == true) { + ui->label_Verification->setText("Invalid date"); + } + else { + ui->label_Verification->setText("Invalid number"); + } + } +} + +void MainWindow::on_PB_Quitter_clicked() { + exit(0); +} diff --git a/mainwindow.h b/mainwindow.h new file mode 100644 index 0000000..f26c9d8 --- /dev/null +++ b/mainwindow.h @@ -0,0 +1,29 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include "CVerif_CB.h" + +namespace Ui { + class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private slots: + void on_PB_Verifier_clicked(); + void on_PB_Quitter_clicked(); + +private: + Ui::MainWindow *ui; + + CVerif_CB *carteCB; +}; + +#endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui new file mode 100644 index 0000000..034b50a --- /dev/null +++ b/mainwindow.ui @@ -0,0 +1,484 @@ + + + MainWindow + + + + 0 + 0 + 450 + 350 + + + + + 450 + 350 + + + + + 450 + 350 + + + + + + + + + 85 + 170 + 255 + + + + + + + 85 + 170 + 255 + + + + + + + 85 + 170 + 255 + + + + + + + + + 85 + 170 + 255 + + + + + + + 85 + 170 + 255 + + + + + + + 85 + 170 + 255 + + + + + + + + + 85 + 170 + 255 + + + + + + + 85 + 170 + 255 + + + + + + + 85 + 170 + 255 + + + + + + + + Vérification Carte Bancaire + + + + :/logo-cb.jpg:/logo-cb.jpg + + + background-color: rgb(85, 170, 255); + + + + + + 160 + 210 + 131 + 31 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 16 + + + + background-color: rgb(255, 255, 255); + + + Verify + + + + + + 130 + 60 + 51 + 20 + + + + + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:14pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Number</span></p></body></html> + + + + + + 190 + 110 + 31 + 21 + + + + / + + + Qt::AlignCenter + + + + + + 180 + 60 + 141 + 20 + + + + + MS Shell Dlg 2 + 10 + 50 + false + false + + + + font: 10pt "MS Shell Dlg 2"; +background-color: rgb(255, 255, 255); + + + 5132865025007267 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 160 + 110 + 31 + 20 + + + + + MS Shell Dlg 2 + 10 + 50 + false + false + + + + font: 10pt "MS Shell Dlg 2"; +background-color: rgb(255, 255, 255); + + + 12 + + + Qt::AlignCenter + + + + + + 220 + 110 + 71 + 20 + + + + + MS Shell Dlg 2 + 10 + 50 + false + false + + + + font: 10pt "MS Shell Dlg 2"; +background-color: rgb(255, 255, 255); + + + 2020 + + + Qt::AlignCenter + + + + + + 10 + -1 + 431 + 31 + + + + + 15 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:15pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Credit Card Verification</span></p></body></html> + + + Qt::AlignCenter + + + + + + 350 + 330 + 101 + 20 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:7pt; font-style:italic;">© PouletEnSlip - 2022</span></p></body></html> + + + + + + 370 + 290 + 61 + 31 + + + + QPushButton { +font: 12pt "Comic Sans MS"; +background-color: rgb(85, 200, 0); +border-radius: 10px; +} + +QPushButton::hover { +background-color: rgb(255, 220, 80); +border-style: inset; +} + +QPushButton::pressed { +background-color: rgb(255, 185, 50); +border-style: inset; +} + + + X + + + + + + 300 + 210 + 111 + 31 + + + + font: 75 10pt "Comic Sans MS"; + + + + + + + + + 10 + 280 + 180 + 60 + + + + + 1000 + 1000 + + + + + + + :/cb.png + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + +