Skip to content

Instantly share code, notes, and snippets.

@scharfie
Last active May 23, 2022 12:21
Show Gist options
  • Save scharfie/396f7852f33d527d7faeac4c2eba678f to your computer and use it in GitHub Desktop.
Save scharfie/396f7852f33d527d7faeac4c2eba678f to your computer and use it in GitHub Desktop.
packing-test
#!/bin/bash
php << 'PHP'
<?php
$f = fopen("packing-test.php.dat", "wb");
$test = pack('A3d', 'Bob', 0);
fwrite($f, $test);
fclose($f);
PHP
ruby <<'RUBY'
File.open("packing-test.ruby.dat", "wb") do |f|
test = ['Bob', 0].pack('A3d')
f.write test
end
RUBY
echo "PHP"
od -xc packing-test.php.dat
echo "RUBY"
od -xc packing-test.ruby.dat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment