// Validation Tests void validation_tests () { std::cout << std::endl << "borZoi Validation Tests" << std::endl; // *********************************************************** // SHA-1 Validation Tests // *********************************************************** std::cout << std::endl << "SHA-1 Validation Tests" << std::endl; OCTETSTR ABC(3); // Message to be hashed ABC[0] = 'a'; ABC[1] = 'b'; ABC[2] = 'c'; BigInt Hash = OS2IP (SHA1 (ABC)); BigInt Hash1 = hexto_BigInt("A9993E364706816ABA3E25717850C26C9CD0D89D"); std::cout << "SHA-1 Hash of {\'a\', \'b\', \'c\'}:" << Hash<< std::endl; if (notValid (Hash == Hash1)) return; Hash = OS2IP (SHA1 ("abc")); std::cout << "SHA-1 Hash of \"abc\":" << Hash << std::endl; if (notValid (Hash == Hash1)) return; BigInt Hash2 = hexto_BigInt("84983E441C3BD26EBAAE4AA1F95129E5E54670F1"); Hash = OS2IP (SHA1 ("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")); std::cout << "SHA-1 Hash of \"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\":" << Hash << std::endl; if (notValid (Hash == Hash2)) return; OCTETSTR million_as(1000000); for (unsigned long i=0; i<1000000; i++) { million_as[i] = 'a'; } BigInt Hash3 = hexto_BigInt("34AA973CD4C4DAA4F61EEB2BDBAD27316534016F"); Hash = OS2IP (SHA1 (million_as)); std::cout << "SHA-1 Hash of one million \'a\'s:" << Hash << std::endl; if (notValid (Hash == Hash3)) return; }
void coEditorTextValueWidget::setValue(const QString &valueName, const QString &value, const QString &readableAttrRule, const QString &attributeDescription, bool, const QRegExp &rx) { fvariable = valueName; fvalue = value; QHBoxLayout *layout; QLabel *valueLabel; QSpacerItem *spacerItem; setObjectName(widgetName); setMaximumSize(QSize(16777215, 100)); setBaseSize(QSize(400, 25)); setToolTip(attributeDescription); layout = new QHBoxLayout(this); layout->setSpacing(0); layout->setMargin(0); layout->setObjectName(QString::fromUtf8("layout")); valueLabel = new QLabel(this); valueLabel->setText(valueName); valueLabel->setObjectName(QString::fromUtf8("valueLabel")); valueLabel->setBaseSize(QSize(150, 22)); QSizePolicy labelSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); labelSizePolicy.setHorizontalStretch(1); labelSizePolicy.setVerticalStretch(0); labelSizePolicy.setHeightForWidth(valueLabel->sizePolicy().hasHeightForWidth()); valueLabel->setSizePolicy(labelSizePolicy); spacerItem = new QSpacerItem(30, 20, QSizePolicy::Preferred, QSizePolicy::Minimum); valueLineEdit = new coEditorValidatedQLineEdit(this); valueLineEdit->setObjectName(valueName); valueLineEdit->setStatusTip(readableAttrRule); QSizePolicy sizePolicy(static_cast<QSizePolicy::Policy>(3), static_cast<QSizePolicy::Policy>(0)); sizePolicy.setHorizontalStretch(2); sizePolicy.setVerticalStretch(0); sizePolicy.setHeightForWidth(valueLineEdit->sizePolicy().hasHeightForWidth()); valueLineEdit->setSizePolicy(sizePolicy); valueLineEdit->setMaximumSize(QSize(16777215, 22)); valueLineEdit->setBaseSize(QSize(200, 22)); valueLineEdit->setAlignment(Qt::AlignRight); valueLineEdit->setDragEnabled(true); if (!rx.isEmpty()) { QValidator *validator = new QRegExpValidator(rx, this); valueLineEdit->setValidator(validator); } // returnPressed is only send, if expression is valid. then we need to call coConfigEntry->setValue // connect(valueLineEdit, SIGNAL(returnPressed()), this, SLOT(commitNewEntryValueData())); valueLineEdit->setText(value); //setText does not call validate valueLineEdit->setModified(false); //create Contextmenu - Delete value deleteValueAction = new QAction(tr("Delete this Value ?"), valueLabel); deleteValueAction->setStatusTip(tr("Delete this value ?")); addAction(deleteValueAction); setContextMenuPolicy(Qt::ActionsContextMenu); if (getType() == coEditorValueWidget::Info || getType() == coEditorValueWidget::InfoName /*value.isEmpty() &&*/ /*&& !required*/) { defaultValue = value; // valueLineEdit->setStyleSheet("background-color: aliceblue"); connect(deleteValueAction, SIGNAL(triggered()), this, SLOT(explainShowInfoButton())); } else { //is valid checks, and sets background color to red if check fails /* if (!empty)*/ valueLineEdit->isValid(); connect(deleteValueAction, SIGNAL(triggered()), this, SLOT(suicide())); } valueLineEdit->adjustSize(); QSize size(250, 45); size = size.expandedTo(minimumSizeHint()); resize(size); //connect to save connect(valueLineEdit, SIGNAL(editingFinished()), this, SLOT(save())); // connect ( valueLineEdit, SIGNAL (returnPressed() ), this, SLOT (save() ) ); //NOTE if we want a nasty nagscreen, connect it here //connect ( valueLineEdit, SIGNAL (notValid() ), , SLOT ( ) ); connect(valueLineEdit, SIGNAL(notValid()), this, SIGNAL(notValid())); layout->addWidget(valueLabel); layout->addItem(spacerItem); layout->addWidget(valueLineEdit); setLayout(layout); }