Created
May 24, 2012 12:48
-
-
Save jasiek/2781381 to your computer and use it in GitHub Desktop.
Convert base-256 byte string to base-10
This file contains hidden or 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 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