I am a C# guy who is desperately trying to learn C++ and port some old code over. Been doing OK so far but the following method has me stumped. If anyone could give me some pointers (sorry for pun) I would be grateful.
C# method:
public static string crappyEncryption(String userKey)
{
StringBuilder eStr = new StringBuilder();
String key1 = "somehorriblelongstring";
String key2 = "someotherhorriblelongstring";
for (int i = 0; i < userKey.Length; i++)
{
eStr.Append(key2[key1.IndexOf(userKey[i])]);
}
return encodeTo64(eStr.ToString());
}
encodeTo64 is a local method which I have solved in C++. This weird method (if you were wondering) was a small encryption method I came up with that we could use mobile cross platform for non-essential string encryption.
Thanks very much
Not gonna give you the whole code, but some pointers:
StringBuildercan be substituted by astd::stringstream.Stringis astd::stringlength(),find()andoperator[].std::stringstreamhasoperator <<forAppend.ToStringisstd::stringstream::str().userKeyby reference.All concepts you don’t understand can easily be found with a google search.