Return to Snippet

Revision: 62010
at January 27, 2013 22:05 by eiger824


Initial Code
#include <iostream>
#include <string.h>

using namespace std;

void main(){
	char password[50]={0};
	int aux_password[50]={0};
	int encrypted_password[50]={0};
	char encrypted_password2[100]={0};
	char final_encryption[100]={0};
	int option;
	cout<<"Type a password to encrypt (0-9,A-Z,a-z): ";
	gets_s(password);
	cout<<"Select encryption level:"<<endl;
	cout<<"\t1.Simple mode."<<endl;
	cout<<"\t2.Advanced mode."<<endl;
	cin>>option;
	switch (option){
	case 1: 
		cout<<">>Typed password: '";
		for (int i=0;i<strlen(password);i++){
			cout<<password[i];
		}cout<<"' "<<endl;
		cout<<">>Encrypted password: ";
		for(int i=0;i<strlen(password);i++){
			encrypted_password[i]=password[i]+12;
			cout<<encrypted_password[i];
		}cout<<endl;	break;	
	case 2: cout<<">>Typed password: '";
		for (int i=0;i<strlen(password);i++){
			cout<<password[i];
		}cout<<"' "<<endl;
		cout<<">>Encrypted password: ";
		for(int i=0;i<(strlen(password)*2);i++){
			aux_password[i]=password[i]+7;
			encrypted_password2[2*i+1]=aux_password[i];
			encrypted_password2[2*i]=i+189;
			final_encryption[i]=encrypted_password2[i];
			cout<<final_encryption[i];
		}cout<<endl;
		break;	
	}
	cout<<"Developed by Santi Pagola."<<endl;
	system("pause");
}

Initial URL
http://`programmingeiger824.blogspot.com

Initial Description
A C++ algorithm which encrypts an alphanumeric password, asking the user to choose the encryption level.

Initial Title
Encrypting Passwords in C++

Initial Tags
code, c++

Initial Language
C++