Clan x86

Technical (Development, Security, etc.) => General Programming => Topic started by: Joe on September 03, 2005, 09:50:02 pm

Title: [Java] Hex Encoding Plugin (JavaOp)
Post by: Joe on September 03, 2005, 09:50:02 pm
   public String queuingText(String text, Object data) {
      String txt[] = text.split(" ");
      String ret;
        if(txt[0] == "/hex") {
           for(int i = 1; i > text.length() - 5; i++) {
              
           }
        }
      return ret;
   }


Basically, I've got the easy stuff down. I see if the left end of the string says "/hex", and if it does, I loop through the rest. Whats left to do is..

1) Cast the ASCII value of the byte at text.substr(i, 1) to a numeric data type (int?).
2) Cast the number to hex
3) Cast the hex to a string
4) Pad the string with a 0 at the left, asuing its needed.
5) Append the string to "ret"

What I need help with..
1, 2

I asume that the hex would be a string, anyhow. Padding shouldn't be too hard, and appending a string is childs play.
Title: Re: [Java] Hex Encoding Plugin (JavaOp)
Post by: Newby on September 03, 2005, 09:51:26 pm
Shrug. I don't know Java. Why did you link me to this? :p
Title: Re: [Java] Hex Encoding Plugin (JavaOp)
Post by: MyndFyre on September 03, 2005, 09:55:40 pm
Code: [Select]
String pref = "0x";
return pref.concat(Integer.toString(Integer.parseInt(txt[1]), 16);
Title: Re: [Java] Hex Encoding Plugin (JavaOp)
Post by: Joe on September 03, 2005, 09:58:43 pm
*crosses fingers*

   public String queuingText(String text, Object data) {
      String txt[] = text.split(" ");
      String ret;
        if(txt[0] == "/hex") {
           for(int i = 1; i > text.length() - 5; i++) {
              ret = ret.concat(Integer.toString(Integer.parseInt(text.substring(i, 1)), 16));
           }
        }
      return ret;
   }
Title: Re: [Java] Hex Encoding Plugin (JavaOp)
Post by: Ergot on September 03, 2005, 10:18:25 pm
Wasn't there that whole "encode" command on JavaOp1 ?
Title: Re: [Java] Hex Encoding Plugin (JavaOp)
Post by: Joe on September 03, 2005, 10:23:26 pm
I think that was iago's Gaim plugin, but it was in C++. I may just have to look though.
Title: Re: [Java] Hex Encoding Plugin (JavaOp)
Post by: Joe on September 03, 2005, 11:47:13 pm
http://www.javaop.com/~joe/vbscript/HexEncode.txt
Title: Re: [Java] Hex Encoding Plugin (JavaOp)
Post by: iago on September 06, 2005, 03:24:16 pm
You should make it more universal and use a Command plugin, so it'll catch "/hex" and "?hex".  Make "hex" a command requiring flags "T". 
Title: Re: [Java] Hex Encoding Plugin (JavaOp)
Post by: Joe on September 06, 2005, 11:43:05 pm
iago, arround 4-6 our time tomorrow, mind contacting me? I wanna show you what I have. I had it load alright, but it didn't catch the /hex. Oops, callbacks weren't registered. Boom! Bye plugin!