Passing base64 encoded strings in URL

前端 未结 10 1642
臣服心动
臣服心动 2020-11-22 03:11

Is it safe to pass raw base64 encoded strings via GET parameters?

10条回答
  •  既然无缘
    2020-11-22 04:06

    Its a base64url encode you can try out, its just extension of joeshmo's code above.

    function base64url_encode($data) {
    return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
    }
    
    function base64url_decode($data) {
    return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT));
    }
    

提交回复
热议问题