Skip to content

Commit

Permalink
fix(app): radix64 decode issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Leon406 committed May 7, 2022
1 parent e88d656 commit 48e140e
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions app/src/main/kotlin/me/leon/encode/base/Base64.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ fun ByteArray.base64(dict: String = BASE64_DICT, needPadding: Boolean = true) =
fun String.base64Decode(dict: String = BASE64_DICT) =
stripAllSpace() // remove all space RFC 2045定义,每行为76个字符,行末加入\r\n
.toCharArray()
// bc url base64不遵守 RFC 2045,Commons Codec 遵守 RFC 2045,没有padding
.filter { it != '=' && it != '.' }
.filter { dict.contains(".") || !dict.contains(".") && it != '=' && it != '.' }
.joinToString("") {
dict
.ifEmpty { BASE64_DICT }
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions testdata/encode/radix10.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1916850967896681345870693862611931789614436539962913401095350402234325684881885811965102220272494
1 change: 1 addition & 0 deletions testdata/encode/radix32.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
smu81pcfi7irf9f5gmruj6s6sm88g832f4g6opbfdoq30di06kp70rrad5iisore
1 change: 1 addition & 0 deletions testdata/encode/radix64.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3Zw.3W8P3Zcj3WU14XsE3XAGGEH3GEvjZ02yKBX.LRHuZ0nnXQ3hZe
1 change: 1 addition & 0 deletions testdata/encode/radix8.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
34557100345437107455572274541333751467033454410404030474440330625573343206015440065144701573246454513461556

0 comments on commit 48e140e

Please sign in to comment.