diff --git a/Jenkinsfile b/Jenkinsfile index 53a2752..ccab3f4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -40,6 +40,7 @@ pipeline { post { always { archiveArtifacts artifacts: "*.tgz", fingerprint: true + archiveArtifacts artifacts: "out/*.bin", fingerprint: true deleteDir() } } diff --git a/bin/dbikc.dart b/bin/dbikc.dart new file mode 100644 index 0000000..23fce64 --- /dev/null +++ b/bin/dbikc.dart @@ -0,0 +1,31 @@ +import 'dart:io'; + +import 'package:libac_dart/argparse/Args.dart'; +import 'package:libac_dart/argparse/Builder.dart'; +import 'package:libac_dart/argparse/CLIHelper.dart'; +import 'package:libac_dart/argparse/types/Bool.dart'; +import 'package:libac_dart/argparse/types/String.dart'; +import 'package:libac_dart/utils/DBIKC.dart'; + +Future main(List args) async { + Arguments defaults = ArgumentsBuilder.builder() + .withArgument(StringArgument( + name: "value", value: "", description: "Text to encode/decode")) + .withArgument(BoolArgument(name: "help", description: "This help text")) + .build(); + + var helpText = CLIHelper.makeArgCLIHelp(defaults); + var HEADER = "Double Breasted Interrupted Key Cipher\nVersion: 1.0\n\n"; + + Arguments parsed = await CLIHelper.parseArgs(args, Arguments()); + if (parsed.hasArg("help") || !parsed.hasArg("value")) { + print("${HEADER}${helpText}"); + exit(0); + return 0; + } else { + print(DoubleBreastedInterruptedKeyCipher.encode( + parsed.getArg("value")!.getValue())); + } + + return 0; +} diff --git a/compile.sh b/compile.sh index 5fc41c4..b7dff5b 100755 --- a/compile.sh +++ b/compile.sh @@ -6,4 +6,5 @@ mkdir out rm -rf out/* flutter pub publish -f --skip-validation dart compile exe -o out/server_test bin/server_test.dart -dart compile exe -o out/client_test bin/client_test.dart \ No newline at end of file +dart compile exe -o out/client_test bin/client_test.dart +dart compile exe -o out/dbikc.bin bin/dbikc.dart \ No newline at end of file diff --git a/lib/utils/DBIKC.dart b/lib/utils/DBIKC.dart new file mode 100644 index 0000000..ad728b3 --- /dev/null +++ b/lib/utils/DBIKC.dart @@ -0,0 +1,61 @@ +class DoubleBreastedInterruptedKeyCipher { + static String encode(String text) { + // Define the vowel and consonant lists + List vowels = ['A', 'E', 'I', 'O', 'U']; + List consonants = [ + 'B', + 'C', + 'D', + 'F', + 'G', + 'H', + 'J', + 'K', + 'L', + 'M', + 'N', + 'P', + 'Q', + 'R', + 'S', + 'T', + 'V', + 'W', + 'X', + 'Y', + 'Z' + ]; + + // Create a map for easy lookups + Map vowelMap = {}; + Map consonantMap = {}; + + // Fill the maps by mirroring the lists + for (int i = 0; i < vowels.length; i++) { + vowelMap[vowels[i]] = vowels[vowels.length - 1 - i]; + } + + for (int i = 0; i < consonants.length; i++) { + consonantMap[consonants[i]] = consonants[consonants.length - 1 - i]; + } + + // Encode the text + StringBuffer encoded = StringBuffer(); + for (int i = 0; i < text.length; i++) { + String char = text[i].toUpperCase(); + if (vowelMap.containsKey(char)) { + encoded.write(vowelMap[char]); + } else if (consonantMap.containsKey(char)) { + encoded.write(consonantMap[char]); + } else { + encoded.write(char); // Keep non-alphabet characters unchanged + } + } + return encoded.toString(); + } + + static String decode(String text) { + // The decoding process is the same as encoding for this cipher + return encode(text); + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 48921d1..6322a10 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: libac_dart description: "Aria's Creations code library" -version: 1.2.072224+1906 +version: 1.2.072724+0210 homepage: "https://zontreck.com" diff --git a/test/ciphers.dart b/test/ciphers.dart new file mode 100644 index 0000000..eed6764 --- /dev/null +++ b/test/ciphers.dart @@ -0,0 +1,9 @@ +import 'package:libac_dart/utils/DBIKC.dart'; +import 'package:test/expect.dart'; +import 'package:test/scaffolding.dart'; + +void main() { + test("DBIKC", () { + expect("KAZNIA", DoubleBreastedInterruptedKeyCipher.encode("RUBNIU")); + }); +}