Post: C++ String Encryption [SourceCode]
02-10-2011, 12:06 AM #1
(adsbygoogle = window.adsbygoogle || []).push({}); I created a header file that allows you to encrypt a string by passing it solely to a

stringEncryption.h
    
#include <iostream>
#include <string>

using namespace std;

void enString(string& text)
{
string enText = "";
int charNum = 0;

for(int i=0;i<text.length();i++)
{
charNum = int(text[i]);
#CENSORED CODE#
#CENSORED CODE#
#CENSORED CODE#
#CENSORED CODE#
enText+=char(charNum);
}
text = enText;
return;
}

void deString(string& enText)
{
string text = "";
int charNum = 0;

for(int i=0;i<enText.length();i++)
{
charNum = int(enText[i]);
#CENSORED CODE#
#CENSORED CODE#
#CENSORED CODE#
#CENSORED CODE#
text+=char(charNum);
}
enText = text;
return;
}


    
#include <iostream>
#include <string>
#include "stringEncryption.h"

using namespace std;

int main()
{
string text= "My string to be encrypted!";

cout<<"Text: "<<text<<endl;

enString(text);
cout<<"Encrypted Text: "<<text<<endl;

deString(text);
cout<<"Encrypted Text: "<<text<<endl;

system("PAUSE");
return EXIT_SUCCESS;
}


Output:
    
Text: My string to be encrypted!
Encrypted Text: →FÝ@A?6;4ÝA<Ý/2Ý2;0?F=A21¯
Encrypted Text: My string to be encrypted!
Press any key to continue . . .


I will only release the full header file to developers only.
02-10-2011, 12:09 AM #2
Hey im a coder/developer. I write code in C++ and vb6. Would you please give me the full header because ive been looking into this just really havnt thought bout how to make it. And im a little new to c++ if thats to say, but im pretty pro with vb6. Thanks a bunch +rep
02-10-2011, 05:27 PM #3
Girby2K11
☮ ☯ ☢ ✔ ➝
Originally posted by boyyo11 View Post
Hey im a coder/developer. I write code in C++ and vb6. Would you please give me the full header because ive been looking into this just really havnt thought bout how to make it. And im a little new to c++ if thats to say, but im pretty pro with vb6. Thanks a bunch +rep


isnt
    #include <iostream> 
#include <string>

using namespace std;

void enString(string& text)
{
string enText = "";
int charNum = 0;

for(int i=0;i<text.length();i++)
{
charNum = int(text[i]);
#CENSORED CODE#
#CENSORED CODE#
#CENSORED CODE#
#CENSORED CODE#
enText+=char(charNum);
}
text = enText;
return;
}

void deString(string& enText)
{
string text = "";
int charNum = 0;

for(int i=0;i<enText.length();i++)
{
charNum = int(enText[i]);
#CENSORED CODE#
#CENSORED CODE#
#CENSORED CODE#
#CENSORED CODE#
text+=char(charNum);
}
enText = text;
return;
}


the header file, just put in main.cpp #include "stringEncryption.h"
02-10-2011, 06:16 PM #4
Originally posted by Girby2K11 View Post
isnt

the header file, just put in main.cpp #include "stringEncryption.h"


I have censored the encryption equation with #CENSORED CODE#

This is a very basic encryption method, so basic releasing the full code here means anyone can use a plain calculator to decrypt any file save with this method :P
02-11-2011, 11:26 PM #5
Ritztro
I am a Game Developer
Originally posted by TheUberFail View Post
I have censored the encryption equation with #CENSORED CODE#

This is a very basic encryption method, so basic releasing the full code here means anyone can use a plain calculator to decrypt any file save with this method :P


Hey can I have the full header? This could be usefull to me if I ever needed it to encrypt my pikin sticks file.
02-12-2011, 10:42 AM #6
Originally posted by Dutch View Post
Hey can I have the full header? This could be usefull to me if I ever needed it to encrypt my pikin sticks file.


You must login or register to view this content. Winky Winky

The following user thanked TheUberFail for this useful post:

Ritztro

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo