Last active
August 29, 2015 14:17
-
-
Save ruseel/c44c37bc7b10190f8908 to your computer and use it in GitHub Desktop.
urlsafe_base64가 ruby와 perl간에 호환이 되는 걸까? 둘다 +/를 -_ 로 바꾸는 것으로..
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
| use 5.010; | |
| use UUID::Tiny; | |
| use MIME::Base64::URLSafe; | |
| foreach(1..1000000) { | |
| $v=create_UUID(UUID_V1); | |
| say $v.urlsafe_b64encode($v); | |
| } |
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
| 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