28

サンプル A (org.apache.commons.codec.binary.Base64 を使用):

Base64.encodeBase64("foobar".getBytes()); 

サンプル B (android.util.Base64 を使用):

Base64.encode("foobar".getBytes(), Base64.DEFAULT); 

これらは同じ文字列を生成しますか?

4

1 に答える 1

81

いいえ、違いは、デフォルト設定では、Android の Base64 に行末記号が含まれていることです。Apache エンコーディングと同じ結果を得るには、Base64.NO_WRAP を使用します。

于 2013-07-28T19:42:31.563 に答える