X Tutup
Skip to content

Commit b00facf

Browse files
committed
Add base 64 encoding support
1 parent 2a4832c commit b00facf

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
encoding
2+
base64Encode: aByteArray
3+
"Base64 encode the given byte array and answer the result as a String."
4+
self subclassResponsibility
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
encoding
2+
base64Encode: aByteArray
3+
^ aByteArray base64Encoded
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
tests
2+
testBase64Encode
3+
| input |
4+
input := #(
5+
(97 110 121 32 99 97 114 110 97 108 32 112 108 101 97 115 117 114 101 46) 'YW55IGNhcm5hbCBwbGVhc3VyZS4='
6+
(97 110 121 32 99 97 114 110 97 108 32 112 108 101 97 115 117 114 101) 'YW55IGNhcm5hbCBwbGVhc3VyZQ=='
7+
(97 110 121 32 99 97 114 110 97 108 32 112 108 101 97 115 117 114) 'YW55IGNhcm5hbCBwbGVhc3Vy'
8+
(97 110 121 32 99 97 114 110 97 108 32 112 108 101 97 115 117) 'YW55IGNhcm5hbCBwbGVhc3U='
9+
(97 110 121 32 99 97 114 110 97 108 32 112 108 101 97 115) 'YW55IGNhcm5hbCBwbGVhcw==').
10+
1 to: input size by: 2 do: [ :index |
11+
| decoded expected |
12+
decoded := GRPlatform current base64Encode: (input at: index) asByteArray.
13+
expected := input at: index + 1.
14+
self assert: decoded = expected ]

0 commit comments

Comments
 (0)
X Tutup