Welcome to SerpentsPoison!
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
 
 

Display results as :
 


Rechercher Advanced Search

CBC Encryption

Wed Mar 25, 2015 6:41 pm by ORLP2

For those who don't know me, I am ORLP (lowercase or upper-case will do, I honestly aren't fussed). I am a Computer Science and cryptography enthusiast. I am looking to broaden my horizon within the "computer security" scene, even if that means joining a newly-crafted forum to get my name across and meet other people who have similar interests as me.

I would like to start by saying I'm …

Comments: 0

Operating System Poll

Tue Mar 17, 2015 7:34 pm by Orianthi

So what operating systems do y'all use?

I use: Windows(7), Linux(Debian, Ubuntu, Mint, Arch Linux, Bieban, Fedora), OS X(Yosemite, Maveriks)

Comments: 0

Who is online?
In total there is 1 user online :: 0 Registered, 0 Hidden and 1 Guest

None

Most users ever online was 14 on Mon Jun 01, 2020 9:21 pm

Ruby: A small parser that parses xat packets

Go down

Ruby: A small parser that parses xat packets Empty Ruby: A small parser that parses xat packets

Post  Shadow19 Sat Apr 04, 2015 5:34 am

Code:

def parseXat(x)
    return nil if !x #Returns nil if x is NilClass or FalseClass
    return nil if !x["<"] or !x["/>"] or x.length < 3 or x.count('"') % 2 != 0 #Basic XML validation
    b = ""#Empty string to fill raw string into.
    f = 0 #Our flag keeps track of what's happening!
    d = {"name" => "", "attributes" => {}} #Hash to put parsed data into!
    for i in 0..(x.length-1)
        if x[i] == "<" and f == 0
            f = 1
        elsif f == 1
            if x[i] != " " and x[i] != "/"
                b += x[i]
            else
                d["name"] = b
                b = ""
                f = 0
            end
        end
        if x[i] == " " and x[i..-1]["="] and f != 2
            f = 2
        elsif f == 2
            if x[i] != "="
                b += x[i]
            else
                d["attributes"][b] = ""
                f = 0
            end
        end
        if x[i] == '"' and f != 3
            f = 3
        elsif f == 3
            if x[i] != '"'
                d["attributes"][b] += x[i]
            else
                #Then we check for for "'s. (Cause im too lazy to do all the escapes)
                d["attributes"][b] = (d["attributes"][b]['"']) ? d["attributes"][b].gsub('"', '"') : d["attributes"][b]
                b = ""
                f = 0
            end
        end
        if x[i] == ">"
            break #Breaks when we reach a > (indicating our tag is done parsing)
        end
    end
    return d
end
Shadow19
Shadow19
Moderator
Moderator

Posts : 4
Join date : 2015-03-16

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum