T
T
Ternick2019-02-03 16:41:31
C++ / C#
Ternick, 2019-02-03 16:41:31

How to fix Debag Error?

Good day to all !
I'm just a beginner in C++, before that I learned python 3

#include <Windows.h>
#include <fstream>
#include <sstream>
#include <iostream>
#include <string>
#include <iomanip>

#include "C:\Users\terno\Desktop\Crypto ++\modes.h"
#include "C:\Users\terno\Desktop\Crypto ++\aes.h"
#include "C:\Users\terno\Desktop\Crypto ++\filters.h"

#define ERROR_OPENING_FILE  "FILE NOT FOUND"
#pragma warning( disable : 4326)

using namespace std;

string slurp(string filename) {
  stringstream sstr;
  ifstream in("cry_" + filename);
  if (in.is_open())
  {
    sstr << in.rdbuf();
    in.close();
    return sstr.str();
  }
  else {
    in.close();
    ifstream in1(filename);
    if (in1.is_open()) {
      sstr << in1.rdbuf();
      in1.close();
      return sstr.str();
    }
    else {
      cout << ERROR_OPENING_FILE << endl;
      cin.get();
      exit(0);
    }
  }
    
}

string encrypting(string text, string key)
{
  string ciphertext;
  string iv = "Ternick";

  CryptoPP::AES::Encryption aesEncryption((byte *)key.c_str(), CryptoPP::AES::DEFAULT_KEYLENGTH);
  CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcEncryption(aesEncryption, (byte *)iv.c_str());

  CryptoPP::StreamTransformationFilter stfEncryptor(cbcEncryption, new CryptoPP::StringSink(ciphertext));
  stfEncryptor.Put(reinterpret_cast<const unsigned char*>(text.c_str()), text.length() + 1);
  stfEncryptor.MessageEnd();

  return ciphertext;
}

string decrypting(string enctext, string key)
{
  string decryptedtext;
  string iv = "Ternick";

  CryptoPP::AES::Decryption aesDecryption((byte *)key.c_str(), CryptoPP::AES::DEFAULT_KEYLENGTH);
  CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption(aesDecryption, (byte *)iv.c_str());

  CryptoPP::StreamTransformationFilter stfDecryptor(cbcDecryption, new CryptoPP::StringSink(decryptedtext));
  stfDecryptor.Put(reinterpret_cast<const unsigned char*>(enctext.c_str()), enctext.size());
  stfDecryptor.MessageEnd();

  return decryptedtext;
}

void main()
{
  string text;
  string key;

  setlocale(LC_ALL, "rus");
  cout << "Введите текст : \n";
  cin >> text;
  cout << "Введите ключ для шифровки :\n";
  cin >> key;
  cout<<encrypting(text, key);
  cout<<("\n==================================\n");
  string enctext;
  string deckey;

  cout << "Введите зашифрованный текст : \n";
  cin >> enctext;
  cout << "Введите ключ для дешифровки :\n";
  cin >> deckey;
  cout << decrypting(enctext, deckey);

  system("pause");
}

When running in debug mode, when trying to decrypt, it throws an error :(
W6J3CI1jR-CWDfe4YffuPg.png
All libraries are correctly imported (linked), compiled :)
I wanted to do aes encryption :)
And segment into 2 parts ;)
Encryption and decryption :)
And here is the result of my code :( - Error
I have no thoughts, I don’t know what to do (the example works) :(

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2019-02-04
@jcmvbkbc

I don't know what to do

click on "Abort" and look in the debugger where this one abort()is, why it is there and how the program got there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question