you can't really credit google for this, can you?
This is a discussion on R63b - Perfect packet char filter within the Habbo Releases forums, part of the Habbo Hotel category; Hi, I've made a packet filter that filters ANY char other then A-Z a-z 0-9 and - For example, you ...
Hi, I've made a packet filter that filters ANY char other then A-Z a-z 0-9 and -
For example, you will get:
Received packet [0][0][0][36][15][160][0][32]RELEASE63-201205240929-144271078
Code:
Credits:PHP Code:public string FromCharToString(string Data)
{
string Filtered = Data;
Regex lettersOnly = new Regex("^[a-zA-Z]{1,25}$");
Regex numbersOnly = new Regex("^[0-9]$");
foreach (char C in Filtered)
{
if (C.ToString() == "-" || lettersOnly.IsMatch(C.ToString()) || numbersOnly.IsMatch(C.ToString()))
continue;
Filtered = Filtered.Replace(C.ToString(), "[" + (int)C + "]");
}
return Filtered;
}
Me - creating code
Google - example regex.
Yes. It's true, I am scared of vaginas.
you can't really credit google for this, can you?
Maybe you should tell us where to put this code.
Suggestion: Show us some results!
Sent from my DROID RAZR using Tapatalk 2
Still don't get what I put with packets to put them into an emulator..
Code complete, with modifications to save packets, packets writing, among others.
Sorry For My Bad English, I'm Brazillian!
Enjoy It :DCode:using System; using System.Collections.Generic; using System.Linq; using System.Resources; using System.Text.RegularExpressions; using System.Text; /* * By Droppy and George2000 * Do not remove this -> Compulsory license in the 'Creative Commons License' (Which we are using now) */ namespace ConsoleApplication20 { class Program { public static void FromCharToString(string Data) { string Filtered = Data; Regex lettersOnly = new Regex("^[a-zA-Z]{1,25}$"); Regex numbersOnly = new Regex("^[0-9]$"); foreach (char C in Filtered) { if (C.ToString() == "-" || lettersOnly.IsMatch(C.ToString()) || numbersOnly.IsMatch(C.ToString())) continue; Filtered = Filtered.Replace(C.ToString(), "[" + (int)C + "]"); } TimeSpan span = (DateTime.Now - DateTime.Now); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("Result: "); Console.ResetColor(); Console.WriteLine(Filtered); Console.WriteLine("Saved in lastPacket.txt"); string[] Write = { "###################################", "### Credits: Droppy, George2000 ###", "###################################", "Packets (decoded): " + Filtered, "Packets (encoded): " + Data }; System.IO.File.WriteAllLines(@"lastPacket.txt", Write); Console.WriteLine(" "); } static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("############################################################"); Console.WriteLine("### By: Droppy and George2000 - Creative Commons License ###"); Console.WriteLine("############################################################"); Console.WriteLine("### The last package will be saved in lastPacket.txt ###"); Console.WriteLine("############################################################"); Console.WriteLine(" "); Console.ResetColor(); Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("Started!"); Console.ResetColor(); Console.WriteLine(" "); goto Programe; Programe: Console.ForegroundColor = ConsoleColor.Blue; Console.Write("Write Packets: "); Console.ResetColor(); string phrase = Console.ReadLine(); FromCharToString(phrase); goto Programe; } } } //Enjoy the code!
Slow algorithm is slow :)
#1: Each time you call the function, you have to create two new Regexes each time.
#2: Running a for-statement on a string is faster than a foreach :) (Read on MSDN)
#3: This thing could have been done way easier, like this :D
http://pastebin.com/cMGVgDLB
Code may be a bit longer, but it is way faster :)
- Martin
Last edited by maritnmine; 25-05-12 at 11:50 AM.
Why isn't the method static?