#include "bbstdEncrypting.h"
#include "bbstdPackage.h"
+#include "bbtkBlackBoxInputConnector.h"
+
#include <iostream>
#include <string>
namespace bbstd
{
+class Connection;
+
//
//
// https://stackoverflow.com/questions/66380465/c-encoding-decoding
virtual std::string decode(std::string secret) = 0;
};
-
-
class shift_encryptor : public encryptor
{
int shift;
{
// Your code starts here
- char c_original[74] = { ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j','k', 'l', 'm', 'n', 'o', 'p', 'q','r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9','.',',',':',';','@','*','$','/','-','_','A','B','C','D','E','J','G','H','I','J', 'K','L','M','N','O','P','Q', 'R','S','T','U', 'V','W','X', 'Y','Z' };
-
-
+ char c_original[73] = {
+ ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
+ 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2',
+ '3', '4', '5', '6', '7', '8', '9', '.', ',', ':',
+ ';', '@', '*', '$', '/', '-', '_', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
+ 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z' };
+
+
+
+ this->shift = this->shift % 73;
+
std::string original_result = "";
for (int i = 0; i < original.length(); i++)
{
std::string decode(std::string secret)
{
// Your code starts here
- char c_secret[74] = { ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j','k', 'l', 'm', 'n', 'o', 'p', 'q','r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9','.',',',':',';','@','*','$','/','-','_','A','B','C','D','E','J','G','H','I','J', 'K','L','M','N','O','P','Q', 'R','S','T','U', 'V','W','X', 'Y','Z' };
+ char c_secret[73] = {
+ ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
+ 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2',
+ '3', '4', '5', '6', '7', '8', '9', '.', ',', ':',
+ ';', '@', '*', '$', '/', '-', '_', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
+ 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z' };
+
+
+
+ this->shift = this->shift % 73;
+
std::string secret_result = "";
for (int i = 0; i < secret.length(); i++)
{
std::string encode(std::string original)
{
// Your code starts here
- char c_original[74] = { ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j','k', 'l', 'm', 'n', 'o', 'p', 'q','r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9','.',',',':',';','@','*','$','/','-','_','A','B','C','D','E','J','G','H','I','J', 'K','L','M','N','O','P','Q', 'R','S','T','U', 'V','W','X', 'Y','Z' };
+ char c_original[73] = {
+ ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
+ 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2',
+ '3', '4', '5', '6', '7', '8', '9', '.', ',', ':',
+ ';', '@', '*', '$', '/', '-', '_', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
+ 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z' };
+
std::string original_result = "";
for (int i = 0; i < original.length(); i++)
{
std::string decode(std::string secret)
{
// Your code starts here
- char c_secret[74] = { ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j','k', 'l', 'm', 'n', 'o', 'p', 'q','r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9','.',',',':',';','@','*','$','/','-','_','A','B','C','D','E','J','G','H','I','J', 'K','L','M','N','O','P','Q', 'R','S','T','U', 'V','W','X', 'Y','Z' };
+ char c_secret[73] = {
+ ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
+ 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2',
+ '3', '4', '5', '6', '7', '8', '9', '.', ',', ':',
+ ';', '@', '*', '$', '/', '-', '_', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
+ 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z' };
+
std::string secret_result = "";
for (int i = 0; i < secret.length(); i++)
{
}
if (bbGetInputType()==2)
{
- cypher_encryptor* crypter = new cypher_encryptor("04dw51CeVD23 67W89XYZASTBEfyhazlvjnktbogrumcpiqxs.,:;@*$/-_OHIPKLQRUJGJMNF");
+ cypher_encryptor* crypter = new cypher_encryptor("04dw51CeVD23 67W89XYZASTBEfyhazlvjnktbogrumcpiqxs.,:;@*$/-_OHIPKLQRUJGMNF");
if (bbGetInputMode()==1)
{
bbSetOutputOut ( crypter->encode( bbGetInputIn() ) );
bbSetOutputOut ( encryptDecrypt( bbGetInputIn() ) );
}
}
-
+
+ if (bbGetInputType()==4)
+ {
+ InputConnectorMapType::iterator i = bbGetInputConnectorMap().find("In");
+ bbtk::Connection *c = i->second->GetConnection();
+ int idchar1 = 0;
+ int idchar2 = 8;
+ int idcode = 8;
+ if (c!=NULL)
+ {
+ int pos = c->GetBlackBoxFrom()->bbGetFullName().find("<");
+ std::string idstr1 = c->GetBlackBoxFrom()->bbGetFullName().substr(pos-2,2);
+ idchar1 = std::stoi( idstr1 );
+ std::string idstr2 = c->GetBlackBoxFrom()->bbGetFullName().substr(pos-1,1);
+ idchar2 = idstr2.at(0);
+ idcode = idchar1 + idchar2;
+ }
+
+ shift_encryptor* shiftTest = new shift_encryptor(idcode);
+ cypher_encryptor* crypter = new cypher_encryptor("04dw51CeVD23 67W89XYZASTBEfyhazlvjnktbogrumcpiqxs.,:;@*$/-_OHIPKLQRUJGMNF");
+ if (bbGetInputMode()==1)
+ {
+ bbSetOutputOut ( shiftTest->encode( crypter->encode( bbGetInputIn() )) );
+ } // if
+ if (bbGetInputMode()==2)
+ {
+ bbSetOutputOut ( crypter->decode( shiftTest->decode( bbGetInputIn() )) );
+ } // if
+ }
+
/*
encodeResult = shiftTest->encode("hello world");