Simple Text Encryption

Posts 1–9 of 9 · Page 1 of 1
Simple Text Encryption
Not sure why but I had a sudden urge to share this... It is my way of encrypting text thru vectors
Code:
/*
*	Author: Defcon Noob :)
*	July 20, 2011
*/

#include <iostream>
#include <Windows.h>
#include <string>
#include <time.h>
#include <vector>
#include <math.h>
#include <stdio.h>


using namespace std;
int random;
void encrypt( string &m, vector<int> &e); 
void decrypt( string &m, vector<int> &e);

int input;

int main( )
{
	string m;
	vector<int> e;
	int choice;
	int i=0;
		cout << "Input string: " << endl;
		getline(cin, m);
		while(1){
			cout << " " << endl;
			cout << "Enter 0 for encrypt, 1 for decrypt." << endl;
			cout << " " << endl;
			Sleep(500);
			cin >> choice;
			if (choice)
			{
				input=45;
				decrypt(m, e);
			}
			else
			{
				input=45;
				encrypt(m, e);
			}
			Sleep(5000);
		}
	system("pause");
	return 0;
}
void encrypt (string &m, vector<int> &e) 
{
	int size;
	size = m.size();
	for(int i=0; i < size; i++)
	{
		e.push_back((unsigned char)m[i] * input);
		m[i] = ' ';
	}
	cout << " " << endl;
	cout << "Encrypted string is: ";
	cout << " " << endl;
	for (int i = 0; i < e.size(); i++)
		cout << e[i];
	cout << endl;
}
void decrypt(string &m, vector<int> &e) 
{
	int size;
	size = m.size();
	for(int i=0; i < size; i++){
		m[i] = (unsigned char)(e[i] / input );
	}
	cout << " " << endl;
	cout << "Decrypted string is: " << m << endl;
	cout << " " << endl;
	
}
Good job. If you really like encryption you should look up tutorials on Wincrypt.h
Speaking technically, this is encoding not encrypting; there is a fine difference between the two that are typically mixed.

Encrypting will usually involve a key which is used while encrypting or decrypting data; this key defines the particular mathematical process used when recovering or obstructing the data. Where as encoding usually follows the same protocol when transforming all the data into another form (in this case, it just divides all the data by x, and recovers via multiplication.)

A simple & commonly first introduced example of encryption is XOR encryption. Which invovles performing an XOR operation between the key and the data. Notice that in this form of encryption, the output of the data is dependant on the key (Which it is XORed with)
Quote Originally Posted by radnomguywfq3 View Post
Speaking technically, this is encoding not encrypting; there is a fine difference between the two that are typically mixed.

Encrypting will usually involve a key which is used while encrypting or decrypting data; this key defines the particular mathematical process used when recovering or obstructing the data. Where as encoding usually follows the same protocol when transforming all the data into another form (in this case, it just divides all the data by x, and recovers via multiplication.)

A simple & commonly first introduced example of encryption is XOR encryption. Which invovles performing an XOR operation between the key and the data. Notice that in this form of encryption, the output of the data is dependant on the key (Which it is XORed with)
Oh ok .
Quote Originally Posted by radnomguywfq3 View Post
Speaking technically, this is encoding not encrypting; there is a fine difference between the two that are typically mixed.

Encrypting will usually involve a key which is used while encrypting or decrypting data; this key defines the particular mathematical process used when recovering or obstructing the data. Where as encoding usually follows the same protocol when transforming all the data into another form (in this case, it just divides all the data by x, and recovers via multiplication.)

A simple & commonly first introduced example of encryption is XOR encryption. Which invovles performing an XOR operation between the key and the data. Notice that in this form of encryption, the output of the data is dependant on the key (Which it is XORed with)
I Love You!

Leeched.
Leeched.
/Closed.
Apparently this is not leeched as the proof has been provided:





Re-opened.
Lol it's all good welp my new account/start over has been blown out of the water GG
Posts 1–9 of 9 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?