Created
May 24, 2016 06:10
-
-
Save beepony/e5b339b19c363e21d24246a70dd64299 to your computer and use it in GitHub Desktop.
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
#! /usr/bin/ruby -w | |
# encode and decode use ruby base64 lib | |
# use strict model to avoid "\n" problem every 76 characteres | |
require 'base64' | |
decode_string = Base64.strict_encode64(string) | |
encode_string = Base64.strict_decode64(string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
base64 编码默认每 76 个字符添加 \n,这往往导致字符串错误,可以使用严格的编码模式代替,Base64.strict_endcodee64(str)