 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
ZenX Grandmaster Cheater Supreme
Reputation: 1
Joined: 26 May 2007 Posts: 1021 Location: ">>Pointer<<" : Address 00400560 Offset :1FE
|
Posted: Sat Nov 24, 2007 12:58 am Post subject: Here We Go!! C# |
|
|
Ok, Well, Here goes a big request!!
I need quite a bit of help on adding a Log-In system to my Game.
It doesnt have to log in to a server just yet, but rather it save as a .Bin file , and load the User profile from there!
I tried reading a few tutorials on the subject, but just can't implement this the way it sholuld be done~
If you have any solutions, or willing to help, please post it here!
Thanks.
-ZenXChaos- _________________
CEF Moderator since 2007 ^_^
ZenX-Engine |
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Sat Nov 24, 2007 1:08 am Post subject: |
|
|
You should design it first, then post if you have questions on implementation details. _________________
|
|
| Back to top |
|
 |
ZenX Grandmaster Cheater Supreme
Reputation: 1
Joined: 26 May 2007 Posts: 1021 Location: ">>Pointer<<" : Address 00400560 Offset :1FE
|
Posted: Sat Nov 24, 2007 1:09 am Post subject: |
|
|
| appalsap wrote: | | You should design it first, then post if you have questions on implementation details. |
Good Idea.
Didnt think of that.
I was goign to using a Connection with some Simple PHP coding and C# coding.
But im not a big Fan of PHP. _________________
CEF Moderator since 2007 ^_^
ZenX-Engine |
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Sat Nov 24, 2007 1:20 am Post subject: |
|
|
XML.
| Code: |
<User>
<Username>samuri25404</Username>
<Password>********</Password>
</User>
<User>
<Username>ZenX</Username>
<Password>********</Password>
</User>
|
However, encrypt it, and of course, don't actually have the passwords as stars.
I can give you my dad's XML Writer/Reader class (which comes with free encrypt and decrypt methods), if you want it. |
|
| Back to top |
|
 |
ZenX Grandmaster Cheater Supreme
Reputation: 1
Joined: 26 May 2007 Posts: 1021 Location: ">>Pointer<<" : Address 00400560 Offset :1FE
|
Posted: Sat Nov 24, 2007 1:51 am Post subject: |
|
|
| samuri25404 wrote: | XML.
| Code: |
<User>
<Username>samuri25404</Username>
<Password>********</Password>
</User>
<User>
<Username>ZenX</Username>
<Password>********</Password>
</User>
|
However, encrypt it, and of course, don't actually have the passwords as stars.
I can give you my dad's XML Writer/Reader class (which comes with free encrypt and decrypt methods), if you want it. |
Yes, id love that!
Thanks.
I still need to upload this source for you, im just so darn lazy! _________________
CEF Moderator since 2007 ^_^
ZenX-Engine |
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Sat Nov 24, 2007 2:03 am Post subject: |
|
|
=P
No problems.
Here's the XML Class:
| Code: |
using System;
using System.Xml;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Configuration;
namespace Azuresoft //His company, feel free to change this
{
public class XMLWriter
{
public const int offset = 4; //These two global constants are for encryption
public const string prefix = "1`98~**Hehe"; //You can change them to whatever you want
public static System.Type[] Types()
{
List<Type> extraTypes = new List<Type>();
extraTypes.Add(typeof(Name)); //where Name is the name of the class that you want to make
//an XML file for.
//For every class that you have that you want an XML thing for, do the following line
//extraTypes.Add(typeof(CLASS));
return extraTypes.ToArray();
}
public static string path
{ get { return System.Environment.CurrentDirectory;} }
public static string saveDir = path + @"saves\"; //Where you want your file to be saved
public static object Load(object o, string name)
{
string fil = String.Format("{0}{1}.sam", saveDir, name); //It puts the file with the .sam (you can change
if (!System.IO.File.Exists(fil)) //it to whatever you want), into the path which is CurrentDirectory +
{ //your little saveDir thing
return o;
}
string xml = GetFileText(fil);
o = FromXml(xml, o.GetType(), Types());
return o;
}
public static void Save(object o, string name)
{
string toSave = ToXml(o, o.GetType(), Types());
string msg = "";
WriteFile(toSave, String.Format("{0}{1}.sam", saveDir, name), ref msg); //Change he .sam to whatever you want (like .bin, or .zen, or whatever
}
public static string GetFileText(string fileName)
{
string buffer = "";
StreamReader streamReader = File.OpenText(fileName);
try
{
buffer = streamReader.ReadToEnd();
}
finally
{
streamReader.Dispose();
}
buffer = Decrypt(buffer);
return buffer;
}
public static bool WriteFile(string fileContents, string fileName, ref string message)
{
fileContents = Encrypt(fileContents);
bool WriteFile;
string dir = System.IO.Path.GetDirectoryName(fileName);
if (!System.IO.Directory.Exists(dir))
{
System.IO.Directory.CreateDirectory(dir);
}
StreamWriter sw = null;
try
{
if (File.Exists(fileName))
{
File.SetAttributes(fileName, FileAttributes.Archive);
File.Delete(fileName);
}
sw = File.CreateText(fileName);
sw.Write(fileContents);
message = string.Format("File {0} saved succesfully!", fileName);
WriteFile = true;
}
catch (Exception ex)
{
throw new Exception("problem with " + fileName + " " + ex.ToString());
}
finally
{
if (sw != null)
{
sw.Flush();
sw.Close();
}
}
return WriteFile;
}
public static string Encrypt(string toEncrypt)
{
if (toEncrypt.StartsWith(prefix))
{
return toEncrypt;
}
Random rnd = new Random();
string _out = "";
foreach (char c in toEncrypt.ToCharArray())
{
int num = (int)c;
num = num + offset;
_out += ((char)num).ToString();
num = rnd.Next(33, 122);
_out += ((char)num).ToString();
}
_out = prefix + _out;
return _out;
}
public static string Decrypt(string toDecrypt)
{
string _out = "";
int cnt = 2;
int num = 0;
if (!toDecrypt.StartsWith(prefix))
return toDecrypt;
else
toDecrypt = toDecrypt.Replace(prefix, "");
foreach (char c in toDecrypt.ToCharArray())
{
if (cnt % 2 == 0)
{
num = (int)c;
num = num - offset;
_out += ((char)num).ToString();
}
cnt += 1;
}
return _out;
}
public static object FromXml(string Xml, System.Type ObjType, Type[] extraTypes)
{
XmlSerializer ser;
ser = new XmlSerializer(ObjType, extraTypes);
StringReader stringReader = new StringReader(Xml);
XmlTextReader xmlReader;
xmlReader = new XmlTextReader(stringReader);
object obj;
obj = ser.Deserialize(xmlReader);
xmlReader.Close();
stringReader.Close();
return obj;
}
public static string ToXml(object Obj, System.Type ObjType, Type[] extraTypes)
{
XmlSerializer ser;
ser = new XmlSerializer(ObjType, extraTypes);
MemoryStream memStream;
memStream = new MemoryStream();
XmlTextWriter xmlWriter;
xmlWriter = new XmlTextWriter(memStream, Encoding.UTF8);
xmlWriter.Namespaces = true;
ser.Serialize(xmlWriter, Obj);
xmlWriter.Close();
memStream.Close();
string xml;
xml = Encoding.UTF8.GetString(memStream.GetBuffer());
xml = xml.Substring(xml.IndexOf(Convert.ToChar(60)));
xml = xml.Substring(0, (xml.LastIndexOf(Convert.ToChar(62)) + 1));
return xml;
}
}
}
|
And also, you're going to have to create a class called like user or something. And give it this:
| Code: |
class User
{
[Serializable]
string Username = "";
string Password = "";
}
|
So then, you do this in your code
| Code: |
//Writing:
User u = new User();
u.Username = "ZenX";
u.Password = "********"; //Real password
XMLWriter.Save(u,"User");
|
| Code: |
//Reading:
User u = new User();
u = (User)XMLWriter.Load(u,User);
|
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
|
| Back to top |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Sat Nov 24, 2007 4:48 am Post subject: |
|
|
| The game you're maknig is going to be online ? |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
'attach'][$_attach_i]['cat_swf'][$_cat_swf_i]['HEIGHT'] : '') , '">
';
echo '
';
echo '
';
echo '
';
echo '
';
echo '
';
echo '
';
echo '
';
echo '
';
echo '
';
echo '
';
echo ' |
';
echo '
';
echo '