<commit_before>#include "genhash.h"
#include <kparts/part.h>
#include <kicon.h>
#include <kactioncollection.h>
#include <kinputdialog.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <kshell.h>
#include <kapplication.h>
#include <kpluginfactory.h>
#include <kauthorized.h>
#include <kio/netaccess.h>
#include <kparts/fileinfoextension.h>
#include <kfiledialog.h>
#include <QCryptographicHash>
#include <QTextStream>


GenHash::GenHash( QObject* parent, const QVariantList & )
    : KParts::Plugin( parent )
{

    KAction *action = actionCollection()->addAction("generatehash");
    action->setText(i18n( "&Generate MD5 Hash..." ));
    connect(action, SIGNAL(triggered(bool)), SLOT(calcGenHash()));
}

void GenHash::calcGenHash()
{
    KParts::ReadOnlyPart * part = qobject_cast<KParts::ReadOnlyPart *>(parent());

    QString basePath = KFileDialog::getOpenFileName(KUrl("kfiledialog:///konqueror"), i18n("*"), part->widget(), i18n("Open File To make MD5."));

    if (basePath.size()) {
        QString baseString;
        QFile file(basePath);

        if (!file.open(QIODevice::ReadOnly))
        {
            return;
        }

        QTextStream in(&file);
        in >> baseString;

        KMessageBox::information(part->widget(),i18n("Md5 : %1").arg(
                                     QString(QCryptographicHash::hash(baseString.toAscii(), QCryptographicHash::Md5).toHex())));
    }

}

K_PLUGIN_FACTORY(KonqGenHashFactory, registerPlugin<GenHash>();)
K_EXPORT_PLUGIN(KonqGenHashFactory("genhash"))

#include "genhash.moc"
<commit_msg>ascii to bytearray. bug fix<commit_after>#include "genhash.h"
#include <kparts/part.h>
#include <kicon.h>
#include <kactioncollection.h>
#include <kinputdialog.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <kshell.h>
#include <kapplication.h>
#include <kpluginfactory.h>
#include <kauthorized.h>
#include <kio/netaccess.h>
#include <kparts/fileinfoextension.h>
#include <kfiledialog.h>
#include <QCryptographicHash>
#include <QTextStream>


GenHash::GenHash( QObject* parent, const QVariantList & )
    : KParts::Plugin( parent )
{

    KAction *action = actionCollection()->addAction("generatehash");
    action->setText(i18n( "&Generate MD5 Hash..." ));
    connect(action, SIGNAL(triggered(bool)), SLOT(calcGenHash()));
}

void GenHash::calcGenHash()
{
    KParts::ReadOnlyPart * part = qobject_cast<KParts::ReadOnlyPart *>(parent());

    QString basePath = KFileDialog::getOpenFileName(KUrl("kfiledialog:///konqueror"), i18n("*"), part->widget(), i18n("Open File To make MD5."));

    if (basePath.size()) {
        QFile file(basePath);

        if (!file.open(QIODevice::ReadOnly))
        {
            return;
        }

        QByteArray baseByteArray = file.readAll();

        KMessageBox::information(part->widget(),i18n("Md5 : %1").arg(
                                     QString(QCryptographicHash::hash(baseByteArray, QCryptographicHash::Md5).toHex())));
    }

}

K_PLUGIN_FACTORY(KonqGenHashFactory, registerPlugin<GenHash>();)
K_EXPORT_PLUGIN(KonqGenHashFactory("genhash"))

#include "genhash.moc"

{'fraction_non_alphanumeric': 0.16078938854739566, 'fraction_numerical': 0.008411517308314461, 'mean_word_length': 4.321858864027539, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4278480', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1056, 'n_words': 175}