Skip to content

Instantly share code, notes, and snippets.

@asterite
Last active November 23, 2016 13:42
Show Gist options
  • Save asterite/719e478f6f3dfd30a59405897d37dcd7 to your computer and use it in GitHub Desktop.
Save asterite/719e478f6f3dfd30a59405897d37dcd7 to your computer and use it in GitHub Desktop.
require "base64"
require "zlib"
def read(type, bytes_or_io)
IO::ByteFormat::BigEndian.decode(type, bytes_or_io)
end
string = "HISTFAAAAEV42pNpmSzMwMCgyAABTBDKT4GBgdnNYMcCBvsPEBEJISEuATEZMQ4uASkhIR4nrxg9v2lMaxhvMekILGZkKmcCAEf2CsI"
bytes = Base64.decode(string)
cookie = read Int32, bytes[0, 4]
compressed_payload_length = read Int32, bytes[4, 4]
deflate = Zlib::Inflate.new(IO::Memory.new(bytes[8, compressed_payload_length]))
cookie = read Int32, deflate
payload_length = read Int32, deflate
normalizing_index_offset = read Int32, deflate
number_of_significant_value_digits = read Int32, deflate
lowest_trackable_value = read Int64, deflate
highest_trackable_value = read Int64, deflate
integer_to_double_conversion_ratio = read Float64, deflate
rest = deflate.gets_to_end.to_slice
pp cookie,
payload_length,
normalizing_index_offset,
number_of_significant_value_digits,
lowest_trackable_value,
highest_trackable_value,
integer_to_double_conversion_ratio,
rest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment