keygen.cc 1.32 KB
Newer Older
Jan Möbius's avatar
Jan Möbius committed
1 2 3
#include <qapplication.h>
#include <QtGui>
#include <QFile>
Jan Möbius's avatar
Jan Möbius committed
4 5
#include <iostream>
#include "salt.hh"
Jan Möbius's avatar
Jan Möbius committed
6 7 8

int main(int argc, char **argv)
{	
Jan Möbius's avatar
Jan Möbius committed
9 10 11 12 13 14 15 16 17 18 19 20
  QApplication a( argc, argv );

  if (argc == 2) {
    std::cerr  << " Call ./keygen <InfoFile> <Output Key File>" << std::endl;
    exit(1);
  }

  QFile file(argv[1]);

  if (!file.open(QIODevice::ReadOnly|QIODevice::Text))
    std::cerr << "Unable to open file " << std::endl;

Jan Möbius's avatar
Jan Möbius committed
21 22 23 24
  QString name       = file.readLine().simplified();
  QString coreHash   = file.readLine().simplified();
  QString pluginHash = file.readLine().simplified();
  QString macHash    = file.readLine().simplified();
Jan Möbius's avatar
Jan Möbius committed
25 26 27 28 29 30 31 32

  std::cerr << "Generating key for Plugin : " << name.toStdString() << std::endl;
  QString saltPre;
  ADD_SALT_PRE(saltPre);

  QString saltPost;
  ADD_SALT_POST(saltPost);

Jan Möbius's avatar
Jan Möbius committed
33 34 35 36 37
  std::cerr << "Core Hash : " << coreHash.toStdString() << std::endl;
  std::cerr << "Plugin Hash : " << pluginHash.toStdString() << std::endl;

  std::cerr << "macHash is: " << macHash.toStdString()  << std::endl;

Jan Möbius's avatar
Jan Möbius committed
38
  QString keyClear = coreHash + saltPre + pluginHash + saltPost + macHash;
Jan Möbius's avatar
Jan Möbius committed
39
  std::cerr << "keyClear is: " << keyClear.toStdString() << std::endl;
Jan Möbius's avatar
Jan Möbius committed
40 41 42 43 44

  QString keyHash = QCryptographicHash::hash ( keyClear.toAscii()  , QCryptographicHash::Sha1 ).toHex();
  std::cerr << "key is: " << keyHash.toStdString() << std::endl;

  return 0;
Jan Möbius's avatar
Jan Möbius committed
45 46 47

}