gostsum-devel

andr1312e

New member
Сообщения
5
#1
Как посчитать КС файла по госту в с++? Есть ли готовые примеры?
Подключить библиотеку смог, а как ее использовать?
 

andr1312e

New member
Сообщения
5
#2
Решение:
про файл:

Код:
QT -= gui

CONFIG += c++11 console
CONFIG -= app_bundle

SOURCES += \
        main.cpp

LIBS += -L/lib/ -lgost

INCLUDEPATH += /usr/include/gost
DEPENDPATH += /usr/include/gost

Код:


Код:
#include <QCoreApplication>
#include <QFile>
#include <QByteArray>
#include <QDebug>

#include "gost/gostapi.h"

int main(int argc, char *argv[])
{
    QFile file("/home/user/letter.json");
    const bool isFile=file.exsists();
    if(isFile)
    {
        const int fileDescriptor = file.handle();
        const size_t fileSize=file.size();
        unsigned char res[32];
        int gostRes=gost12_hash_file(fileDescriptor, fileSize, res);
        QByteArray arr;
        for (int i=0; i<(sizeof(res)/sizeof(*res)); ++i)
        {
          arr.append(res[i]);
        }
        const QString str=arr.toHex();
        qDebug()<< str;
    }

    return 0;
}
 
Последнее редактирование: