Difference between basic and url base64 encoding in Java 8

后端 未结 2 704
长情又很酷
长情又很酷 2021-02-14 10:27

The Java 8 Base64 library has two variants that can be used in URI building: the \"Basic\" one and the \"URL and Filename safe\". The documentation points to RFC 4648 Table 2 as

2条回答
  •  孤城傲影
    2021-02-14 11:22

    Running some tests, encoding a data URI using base64 "URL and filename safe" produces URIs that are not recognised by Chrome.

    Example: data:text/plain;base64,TG9yZW0/aXBzdW0= is properly decoded to Lorem?ipsum, while its URL-safe counterpart data:text/plain;base64,TG9yZW0_aXBzdW0= is not (ERR_INVALID_URL).

提交回复
热议问题