Base64编码 - 解码问题

时间:2016-02-01 17:22:13

标签: encoding base64 decoding

我读到Base64是确定性算法,并产生独特的结果。考虑这两个编码的base64值:

  

KFNjcmlwdCBYU1MpIFVSTDogaHR0cDovL2xvY2FsaG9zdDo4MDgwL2h0bWxQYXJzZXIvLiB8IElEOiBUaGlzIGlzIElEMC4gfCBDbGFzczogVW5hdmFpbGFibGUuLiB8IFRleHQgQ29udGVudDogCgogICAgRGF0YTogPGlucHV0IG1heGxlbmd0aD0iOTk5OTkiIG5hbWU9ImRhdGEiIHR5cGU9InRleHQiPiA8YnI + CiAgICA8aW5wdXQgdmFsdWU9InN1Ym1pdCIgdHlwZT0ic3VibWl0Ij4KICAgIAogIDxpbnB1dCBvbmNsaWNrPSJqYXZhc2NyaXB0OmFsZXJ0KCdJbnB1dCBJRCBYU1MgLSBtb3VzZWNsaWNrJykiIGF1dG9mb2N1cz0iIj4gIAogICAgIAogICA8c2NyaXB0IGNsYXNzPSJmZmYiPmphdmFzY3JpcHQ6YWxlcnQoJ1NjcmlwdCBGT1JNIFhTUycpPC9zY3JpcHQ +

&安培;

  

KFNjcmlwdCBYU1MpIFVSTDogaHR0cDovL2xvY2FsaG9zdDo4MDgwL2h0bWxQYXJzZXIvLiB8IElEOiBUaGlzIGlzIElEMC4gfCBDbGFzczogVW5hdmFpbGFibGUuLiB8IFRleHQgQ29udGVudDogDQoNCiAgICBEYXRhOiA8aW5wdXQgbWF4bGVuZ3RoPSI5OTk5OSIgbmFtZT0iZGF0YSIgdHlwZT0idGV4dCI + IDxicj4NCiAgICA8aW5wdXQgdmFsdWU9InN1Ym1pdCIgdHlwZT0ic3VibWl0Ij4NCiAgICANCiAgPGlucHV0IG9uY2xpY2s9ImphdmFzY3JpcHQ6YWxlcnQoJ0lucHV0IElEIFhTUyAtIG1vdXNlY2xpY2snKSIgYXV0b2ZvY3VzPSIiPiAgDQogICAgIA0KICAgPHNjcmlwdCBjbGFzcz0iZmZmIj5qYXZhc2NyaXB0OmFsZXJ0KCdTY3JpcHQgRk9STSBYU1MnKTwvc2NyaXB0Pg ==

这两个都给我相同的解码输出。这怎么可能?我无法在这两个值的解码格式之间找到任何明显的差异。

它与UTF 8和ASCII等编码和解码方案有关吗?

1 个答案:

答案 0 :(得分:0)

解码后的字符串不同 - 它们在行尾有不同的CR / LF序列:\n\n (0a0a) vs \r\n\r\n (0d0a0d0a)

00000060  20 54 65 78 74 20 43 6f  6e 74 65 6e 74 3a 20 0a  | Text Content: .|
00000070  0a 20 20 20 20 44 61 74  61 3a 20 3c 69 6e 70 75  |.    Data: <inpu|


00000060  20 54 65 78 74 20 43 6f  6e 74 65 6e 74 3a 20 0d  | Text Content: .|
00000070  0a 0d 0a 20 20 20 20 44  61 74 61 3a 20 3c 69 6e  |...    Data: <in|

提示:使用hexdump -C <file>获取此类输出。