Welcome to the RaGEZONE - MMORPG development forums.

Inventory Encryption/decryption

This is a discussion on Inventory Encryption/decryption within the Tales of Pirates forums, part of the MMO and MMORPG Developments category; I made a partial inventory class which can encrypt/decrypt the inventory, so lets see how far you can go with ...

Results 1 to 2 of 2
  1. #1
    Member
    Rank
    Member
    Join Date
    Feb 2010
    Posts
    43
    Liked
    7

    Inventory Encryption/decryption

    I made a partial inventory class which can encrypt/decrypt the inventory, so lets see how far you can go with it !

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace Inventory.lib
    {
        class inventory
        {
            public string key = "19800216";
    
            public string GetString(byte[] ascii)
            {
                string chr = Encoding.ASCII.GetString(ascii);
    
                return chr;
            }
    
            public byte[] GetBytes(string s)
            {
                byte[] bytes = Encoding.ASCII.GetBytes(s);
    
                return bytes;
            }
    
            public string Decrypt(string input)
            {
                int keyLen = this.key.Length;
    
                input = input.Split('#')[1];
    
                int inputLen = input.Length;
    
                string result = "";
    
                for (int i = 0; i < inputLen; i++)
                {
                    result += (Convert.ToInt32(GetBytes(input[i].ToString())[0]) - Convert.ToInt32(GetBytes(this.key[i % keyLen].ToString())[0])) + "|";
                }
    
                string[] split = result.Split(Convert.ToChar("|"));
    
                result = "";
    
                byte[] temp = new byte[split.Length - 1];
    
                for (int i = 0; i < split.Length - 1; i++)
                {
                    temp[i] = (Convert.ToByte(split[i]));
                }
                return GetString(temp);
            }
    
    
            public string Encrypt(string input)
            {
                int keyLen = this.key.Length;
    
                int inputLen = input.Length;
    
                string result = "";
    
                for (int i = 0; i < inputLen; i++)
                {
                    result += (Convert.ToInt32(GetBytes(input[i].ToString())[0]) + Convert.ToInt32(GetBytes(this.key[i % keyLen].ToString())[0])) + "|";
                }
    
                string[] split = result.Split(Convert.ToChar("|"));
    
                result = "";
    
                byte[] temp = new byte[split.Length - 1];
    
                for (int i = 0; i < split.Length - 1; i++)
                {
                    temp[i] = (Convert.ToByte(split[i]));
                }
                return GetString(temp);
            }
        }
    }

  2. #2
    Member
    Rank
    Member
    Join Date
    Jan 2008
    Posts
    63
    Liked
    2

    Re: Inventory Encryption/decryption

    And now lets see how long it takes you to figure out how to calculate the checksum of the inventory ;-)

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •