keygen.cc 1016 Bytes
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 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
  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;

  QString name       = file.readLine();
  QString coreHash   = file.readLine();
  QString pluginHash = file.readLine();
  QString macHash    = file.readLine();

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

  QString saltPost;
  ADD_SALT_POST(saltPost);

  QString keyClear = coreHash + saltPre + pluginHash + saltPost + macHash;

  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
39 40 41

}