Last active
June 11, 2020 03:10
-
-
Save ctkqiang/fe9702b56c2047e449e68818ee46e84c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "dart:convert"; | |
import "dart:io"; | |
class base64encoder { | |
void encode_text(String textInput) { | |
List encodedText = utf8.encode(textInput); | |
String theBaseStr = base64.encode(encodedText); | |
print(theBaseStr); | |
} | |
void decode_text(String encodedText) { | |
String decodedText = utf8.decode(base64.decode(encodedText.toString())); | |
print(decodedText); | |
} | |
void encode_file(var rawFile) { | |
List fileBytes = new File(rawFile).readAsBytesSync(); | |
print(fileBytes); | |
} | |
} | |
void main () { | |
base64encoder test = new base64encoder(); | |
var a = test.encode_text("ddddddddddddddddddddddddddddddddddddddddddddddddddddd"); | |
var b = test.decode_text(a); | |
print(b); | |
test.encode_file("directory to my file"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment