/tmp/ccAKV0Q4.o: In function `encryption(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)': encryption.cpp:(.text+0xcd6): undefined reference to `getcipher(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int (*) [3])' collect2: ld returned 1 exit status
When I try to compile this code:
Anybody know why?
#include "encryption.h"
#include<iostream>
using namespace std;
string encryption(string toencrypt)
{
for(int i=0;i<(Array_size-toencrypt.length()%Array_size);i++)
{
toencrypt=toencrypt+" ";
}
int cipher[Array_size][Array_size];
string ciphercode="";
getcipher(ciphercode, cipher);
string encrypted=ciphercode;
while(toencrypt.length()>0)
{
string unit_encrypt=toencrypt.substr(0,Array_size);
toencrypt.erase(0,Array_size);
int tomultiply[Array_size];
for(int i=0;i<Array_size;i++)
{
tomultiply[i]=int(unit_encrypt.c_str()[0]);
unit_encrypt.erase(0,1);
}
for(int i=0;i<Array_size;i++)
{
int resultchar=0;
for(int j=0;j<Array_size;j++)
{
resultchar+=tomultiply[j]*cipher[i][j];
}
encrypted+=char((resultchar%229)-26);
}
}
return encrypted;
}
string decryption(string todecrypt)
{
int cipher[Array_size][Array_size];
string ciphercode=todecrypt.substr(0,3);
todecrypt.erase(0,3);
decodecipher(ciphercode,cipher);
string decrypted="";
while(todecrypt.length()>0)
{
string unit_decrypt=todecrypt.substr(0,Array_size);
todecrypt.erase(0,Array_size);
int tomultiply[Array_size];
for(int i=0;i<Array_size;i++)
{
tomultiply[i]=int(unit_decrypt.c_str()[0]);
unit_decrypt.erase(0,1);
}
for(int i=0;i<Array_size;i++)
{
int resultchar=0;
for(int j=0;j<Array_size;j++)
{
resultchar+=tomultiply[j]*cipher[i][j];
}
decrypted+=char((resultchar%229)-26);
}
}
return decrypted;
}
void getcipher(string& whichcipher, int returncipher[Array_size][Array_size])
{
int cipher1[Array_size][Array_size]={{57,-5,46},
{11,-1, 9},
{-1, 0, 1}};
int cipher2[Array_size][Array_size]={{1, 0, 5},
{2, 1, 6},
{3, 4, 0}};
int cipher3[Array_size][Array_size]={{1, 5, 2},
{1, 1, 7},
{0, -3,4}};
string ciph1code="EaP";
string ciph2code="RH!";
string ciph3code="Tfh";
if(whichcipher==ciph1code)
{
for(int i=0;i<Array_size;i++)
{
for(int j=0;j<Array_size;j++)
{
returncipher[i][j]=cipher1[i][j];
}
}
}
else if(whichcipher==ciph2code)
{
for(int i=0;i<Array_size;i++)
{
for(int j=0;j<Array_size;j++)
{
returncipher[i][j]=cipher2[i][j];
}
}
}
else if(whichcipher==ciph3code)
{
for(int i=0;i<Array_size;i++)
{
for(int j=0;j<Array_size;j++)
{
returncipher[i][j]=cipher3[i][j];
}
}
}
}
void decodecipher(string thiscipher, int returncipher[Array_size][Array_size])
{
int cipher1iv[Array_size][Array_size]={{1, -5, 1},
{2,-11,-7},
{-1, 5, 2}};
int cipher2iv[Array_size][Array_size]={{-24,20,-5},
{18,-15, 4},
{5, -4, 1}};
int cipher3iv[Array_size][Array_size]={{-25,26,-33},
{4, -4, 5},
{3, -3, 4}};
string ciph1code="EaP";
string ciph2code="RH!";
string ciph3code="Tfh";
if(thiscipher==ciph1code)
{
for(int i=0;i<Array_size;i++)
{
for(int j=0;j<Array_size;j++)
{
returncipher[i][j]=cipher1iv[i][j];
}
}
}
else if(thiscipher==ciph2code)
{
for(int i=0;i<Array_size;i++)
{
for(int j=0;j<Array_size;j++)
{
returncipher[i][j]=cipher2iv[i][j];
}
}
}
else if(thiscipher==ciph3code)
{
for(int i=0;i<Array_size;i++)
{
for(int j=0;j<Array_size;j++)
{
returncipher[i][j]=cipher3iv[i][j];
}
}
}
}

New Topic/Question
Reply



MultiQuote





|