Skip to content

Instantly share code, notes, and snippets.

@dzucconi
Last active December 20, 2015 10:09
Show Gist options
  • Save dzucconi/6113577 to your computer and use it in GitHub Desktop.
Save dzucconi/6113577 to your computer and use it in GitHub Desktop.
program = "some string"
number = program.bytes.map { |byte| byte.to_s(2).rjust(8, "0") }.join.to_i(2)
# => 139552669917336061109431911
number.to_s(2).scan(/.+?(?=.{8}*\z)/).map { |string| string.to_i(2).chr }.join
# => "some string"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment