version 5.5.1
add SipHash and HalfSipHash for PIDigest
This commit is contained in:
70
main.cpp
70
main.cpp
@@ -2,6 +2,7 @@
|
||||
#include "picodeparser.h"
|
||||
#include "pidigest.h"
|
||||
#include "pihttpclient.h"
|
||||
#include "piliterals.h"
|
||||
#include "pip.h"
|
||||
#include "piunits.h"
|
||||
#include "pivaluetree_conversions.h"
|
||||
@@ -10,7 +11,76 @@ using namespace PICoutManipulators;
|
||||
using namespace PIHTTP;
|
||||
using namespace PIUnits::Class;
|
||||
|
||||
int rcnt = 0, scnt = 0;
|
||||
|
||||
inline PIByteArray SMBusTypeInfo_genHash(PIString n) {
|
||||
PICrypt c;
|
||||
return piSerialize(c.shorthash(n.removeAll(" "), PIString("SMBusDataHashKey").toByteArray()));
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
PICrypt _crypt;
|
||||
// auto ba = PIFile::readAll("logo.png");
|
||||
PIString str = "hello!"_a;
|
||||
PIByteArray ba = str.toAscii();
|
||||
PIByteArray key = PIString("SMBusDataHashKey").toByteArray();
|
||||
|
||||
const int times = 1000000;
|
||||
PITimeMeasurer tm;
|
||||
PISystemTime el;
|
||||
|
||||
tm.reset();
|
||||
piForTimes(times) {
|
||||
PIDigest::calculateWithKey(ba, key, PIDigest::Type::SipHash_2_4_128);
|
||||
}
|
||||
el = tm.elapsed();
|
||||
piCout << "PIDigest" << el.toString();
|
||||
|
||||
tm.reset();
|
||||
piForTimes(times) {
|
||||
_crypt.shorthash(str, key);
|
||||
}
|
||||
el = tm.elapsed();
|
||||
piCout << " sodium" << el.toString();
|
||||
|
||||
tm.reset();
|
||||
piForTimes(times) {
|
||||
PIDigest::calculateWithKey(ba, key, PIDigest::Type::BLAKE2b_128);
|
||||
}
|
||||
el = tm.elapsed();
|
||||
piCout << " blake" << el.toString();
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
PIEthernet *eth_r, *eth_s;
|
||||
eth_r = PIIODevice::createFromFullPath("eth://udp: 192.168.1.25 :10000")->cast<PIEthernet>();
|
||||
eth_s = PIIODevice::createFromFullPath("eth://udp: : : 192.168.1.25:10000")->cast<PIEthernet>();
|
||||
|
||||
eth_r->setReadBufferSize(1_MiB);
|
||||
CONNECTL(eth_r, threadedReadEvent, [](const uchar * readed, ssize_t size) {
|
||||
// piCout << "rec";
|
||||
piMSleep(1);
|
||||
++rcnt;
|
||||
});
|
||||
eth_r->startThreadedRead();
|
||||
|
||||
PIByteArray _ba(1400);
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
eth_s->write(_ba);
|
||||
++scnt;
|
||||
}
|
||||
|
||||
0.2_s .sleep();
|
||||
|
||||
piCout << "snd" << scnt;
|
||||
piCout << "rec" << rcnt;
|
||||
|
||||
piDeleteSafety(eth_r);
|
||||
piDeleteSafety(eth_s);
|
||||
return 0;
|
||||
|
||||
PITranslator::loadLang("ru");
|
||||
/*auto ucl = PIUnits::allClasses();
|
||||
for (auto c: ucl) {
|
||||
|
||||
Reference in New Issue
Block a user