Skip to content

Instantly share code, notes, and snippets.

@jasiek
Created May 24, 2012 12:48
Show Gist options
  • Select an option

  • Save jasiek/2781381 to your computer and use it in GitHub Desktop.

Select an option

Save jasiek/2781381 to your computer and use it in GitHub Desktop.
Convert base-256 byte string to base-10
def debase256(string)
string.reverse.bytes.inject([0, 1]) do |(sum, pow), byte|
[pow * byte.ord, pow * 256]
end.first
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment