aboutsummaryrefslogtreecommitdiff
path: root/src/encryption_functions.cpp
diff options
context:
space:
mode:
authoroldmud0 <oldmud0@users.noreply.github.com>2020-05-22 17:02:32 -0500
committeroldmud0 <oldmud0@users.noreply.github.com>2020-05-22 17:02:32 -0500
commit156a760ebab6839c53f9c613881f0937e814414a (patch)
treefd9fafecd25fbd66f0e4f8101f856c8cf68b790e /src/encryption_functions.cpp
parentd89a4370a753f6e1da22349866b1b00f638884a6 (diff)
Full revert to tag 2.6.2
Due to a countless number of changes made to the core that were not fully understood, tested, or documented, it was decided to roll everything back to the last known stable version (2.6.2). Changes dropped include: - Witness needed - Shake - Frame SFX - Multiple custom objections - Multithreaded thumbnail generation - Looping - Various translation additions - "Mirror IC" - Color in IC log - An invocation of clang-format Next time, work together and split your big fork into independently testable feature branches.
Diffstat (limited to 'src/encryption_functions.cpp')
-rw-r--r--src/encryption_functions.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/encryption_functions.cpp b/src/encryption_functions.cpp
index 6669fe15..ffbe0cdb 100644
--- a/src/encryption_functions.cpp
+++ b/src/encryption_functions.cpp
@@ -4,8 +4,8 @@
QString fanta_encrypt(QString temp_input, unsigned int p_key)
{
- // using standard stdlib types is actually easier here because of implicit
- // char<->int conversion which in turn makes encryption arithmetic easier
+ //using standard stdlib types is actually easier here because of implicit char<->int conversion
+ //which in turn makes encryption arithmetic easier
unsigned int key = p_key;
unsigned int C1 = 53761;
@@ -14,7 +14,8 @@ QString fanta_encrypt(QString temp_input, unsigned int p_key)
QVector<uint_fast8_t> temp_result;
std::string input = temp_input.toUtf8().constData();
- for (unsigned int pos = 0; pos < input.size(); ++pos) {
+ for (unsigned int pos = 0 ; pos < input.size() ; ++pos)
+ {
uint_fast8_t output = input.at(pos) ^ (key >> 8) % 256;
temp_result.append(output);
key = (temp_result.at(pos) + key) * C1 + C2;
@@ -22,7 +23,8 @@ QString fanta_encrypt(QString temp_input, unsigned int p_key)
std::string result = "";
- for (uint_fast8_t i_int : temp_result) {
+ for (uint_fast8_t i_int : temp_result)
+ {
result += omni::int_to_hex(i_int);
}
@@ -37,8 +39,9 @@ QString fanta_decrypt(QString temp_input, unsigned int key)
QVector<unsigned int> unhexed_vector;
- for (unsigned int i = 0; i < input.length(); i += 2) {
- std::string byte = input.substr(i, 2);
+ for(unsigned int i=0; i< input.length(); i+=2)
+ {
+ std::string byte = input.substr(i,2);
unsigned int hex_int = strtoul(byte.c_str(), nullptr, 16);
unhexed_vector.append(hex_int);
}
@@ -48,11 +51,13 @@ QString fanta_decrypt(QString temp_input, unsigned int key)
std::string result = "";
- for (int pos = 0; pos < unhexed_vector.size(); ++pos) {
+ for (int pos = 0 ; pos < unhexed_vector.size() ; ++pos)
+ {
unsigned char output = unhexed_vector.at(pos) ^ (key >> 8) % 256;
result += output;
key = (unhexed_vector.at(pos) + key) * C1 + C2;
}
return QString::fromStdString(result);
+
}