Skip to content

Instantly share code, notes, and snippets.

@ruseel
Last active August 29, 2015 14:17
Show Gist options
  • Save ruseel/c44c37bc7b10190f8908 to your computer and use it in GitHub Desktop.
Save ruseel/c44c37bc7b10190f8908 to your computer and use it in GitHub Desktop.
urlsafe_base64가 ruby와 perl간에 호환이 되는 걸까? 둘다 +/를 -_ 로 바꾸는 것으로..
use 5.010;
use UUID::Tiny;
use MIME::Base64::URLSafe;
foreach(1..1000000) {
$v=create_UUID(UUID_V1);
say $v.urlsafe_b64encode($v);
}
require 'base64'
$f = File.open(File.expand_path '~/tmp-bin-base64')
def read_until(ch)
lst = []
while (c = $f.read(1)) != ch
lst << c
end
lst.join
end
while (_bin = $f.read(16))
sb64 = read_until("\n")
if _bin != Base64::urlsafe_decode64(sb64+"==")
puts "ERROR";
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment