Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
encoding
base64Encode: aByteArray
"Base64 encode the given byte array and answer the result as a String."
self subclassResponsibility
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
encoding
base64Encode: aByteArray
^ (Base64MimeConverter mimeEncode: aByteArray readStream) contents
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
encoding
base64Encode: aByteArray
^ aByteArray base64Encoded
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
encoding
base64Encode: aByteArray
^ (Base64MimeConverter base64Encode: aByteArray readStream) contents
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
encoding
base64Encode: aByteArray
^ aByteArray base64Encoded
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
encoding
base64Encode: aByteArray
^ aByteArray base64Encoded
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
encoding
base64Encode: aByteArray
^ aByteArray base64Encoded
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
encoding
base64Encode: aByteArray
^ aByteArray base64Encoded
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
tests
testBase64Encode
| input |
input := #(
(97 110 121 32 99 97 114 110 97 108 32 112 108 101 97 115 117 114 101 46) 'YW55IGNhcm5hbCBwbGVhc3VyZS4='
(97 110 121 32 99 97 114 110 97 108 32 112 108 101 97 115 117 114 101) 'YW55IGNhcm5hbCBwbGVhc3VyZQ=='
(97 110 121 32 99 97 114 110 97 108 32 112 108 101 97 115 117 114) 'YW55IGNhcm5hbCBwbGVhc3Vy'
(97 110 121 32 99 97 114 110 97 108 32 112 108 101 97 115 117) 'YW55IGNhcm5hbCBwbGVhc3U='
(97 110 121 32 99 97 114 110 97 108 32 112 108 101 97 115) 'YW55IGNhcm5hbCBwbGVhcw==').
1 to: input size by: 2 do: [ :index |
| decoded expected |
decoded := GRPlatform current base64Encode: (input at: index) asByteArray.
expected := input at: index + 1.
self assert: decoded = expected ]