Created
April 29, 2009 01:29
-
-
Save jemmyw/103519 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_sid_string(data) | |
sid = [] | |
sid << data[0].to_s | |
rid = "" | |
(6).downto(1) do |i| | |
rid += byte2hex(data[i,1][0]) | |
end | |
sid << rid.to_i.to_s | |
sid += data.unpack("bbbbbbbbV*")[8..-1] | |
"S-" + sid.join('-') | |
end | |
def byte2hex(b) | |
ret = '%x' % (b.to_i & 0xff) | |
ret = '0' + ret if ret.length < 2 | |
ret | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment