A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Rot13 in Dart page! Here, you'll find the source code for this program as well as a description of how the program works.
import 'dart:io';
main(List<String> args) {
if (args.isEmpty || args[0].isEmpty) {
print("Usage: please provide a string to encrypt");
exit(1);
} else {
print( rot13(args[0]) );
}
}
String rot13(String input) {
int aLower = "a".codeUnitAt(0);
int aUpper = "A".codeUnitAt(0);
int nLower = "n".codeUnitAt(0);
int nUpper = "N".codeUnitAt(0);
int zLower = "z".codeUnitAt(0);
int zUpper = "Z".codeUnitAt(0);
List<String> coded = [];
input.codeUnits.forEach((char) {
if ((char >= aLower && char < nLower) ||
(char >= aUpper && char < nUpper)) {
coded.add(new String.fromCharCode(char + 13));
} else if ((char >= nLower && char <= zLower) ||
(char >= nUpper && char <= zUpper)) {
coded.add(new String.fromCharCode(char - 13));
} else {
coded.add(new String.fromCharCode(char));
}
});
return coded.join();
}
Rot13 in Dart was written by:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.