Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77efa81c54 | ||
|
|
51609b1d27 | ||
|
|
40af8401b2 | ||
|
|
0a87ab9e91 | ||
|
|
9c1a8b1bae | ||
|
|
c3ea58f867 |
@@ -0,0 +1,10 @@
|
||||
image: clojure:temurin-11-lein-2.10.0-alpine
|
||||
|
||||
stages:
|
||||
- test
|
||||
|
||||
unit tests:
|
||||
stage: test
|
||||
script:
|
||||
- lein test
|
||||
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.5.3] - 2023-10-05
|
||||
|
||||
### Added
|
||||
- Add the CHANGELOG.
|
||||
|
||||
## [0.5.2] - 2023-10-02
|
||||
|
||||
### Fixed
|
||||
- Fix checking for file existence only when the options are set.
|
||||
- Fix writing to a file only when the option is set.
|
||||
|
||||
## [0.5.1] - 2023-09-28
|
||||
|
||||
### Added
|
||||
- Add the output option to save into a file.
|
||||
- Add the file errors to prevent using an invalid file path.
|
||||
|
||||
## [0.5.0] - 2023-09-22
|
||||
|
||||
### Changed
|
||||
- Update symbol defaults, factories to have only lower alphabets.
|
||||
- Update the Caesar to be case-insensitive and skip unknown symbols.
|
||||
- Update Caesar Analyzers to be case-insensitive and testable.
|
||||
|
||||
## [0.4.3] - 2023-09-21
|
||||
|
||||
### Added
|
||||
- Add the language option for symbols.
|
||||
|
||||
### Changed
|
||||
- Update the CLI to have separated actions and an option initializer.
|
||||
|
||||
## [0.4.2] - 2023-09-18
|
||||
|
||||
### Added
|
||||
- Add tests for the cipher-analyzers module.
|
||||
|
||||
### Changed
|
||||
- Rename the cipher_analyzer module to cipher-analyzers.
|
||||
|
||||
## [0.4.1] - 2023-09-17
|
||||
|
||||
### Added
|
||||
- Add symbol factories for punctuation, space, defaults symbols.
|
||||
- Add the action-type to distinguish the actions.
|
||||
- Add the symbol option and its default.
|
||||
- Add the cracking option.
|
||||
|
||||
### Changed
|
||||
- Rename the language_analyzer module to language-analyzer.
|
||||
- Update the nonsense for the is-nonsense? test.
|
||||
- Rename the symbol_frequences module to symbol-frequences.
|
||||
|
||||
## [0.4.0] - 2023-09-15
|
||||
|
||||
### Added
|
||||
- Add Chi-squared Statistic function to analyze texts.
|
||||
- Add the caesar-analyzers to get the plaintext from a ciphertext.
|
||||
|
||||
## [0.3.5] - 2023-09-14
|
||||
|
||||
### Added
|
||||
- Add the frequences of symbols as defaults.
|
||||
|
||||
## [0.3.4] - 2023-09-13
|
||||
|
||||
### Added
|
||||
- Add a simple language analyzers.
|
||||
|
||||
## [0.3.3] - 2023-09-12
|
||||
|
||||
### Added
|
||||
- Add an option to read a message from a file.
|
||||
|
||||
## [0.3.2] - 2023-09-11
|
||||
|
||||
### Added
|
||||
- Add the CI/CD configuration.
|
||||
|
||||
## [0.3.1] - 2023-09-11
|
||||
|
||||
### Added
|
||||
- Add factories for symbols.
|
||||
- Add tests for factories.
|
||||
|
||||
## [0.3.0] - 2023-09-10
|
||||
|
||||
### Added
|
||||
- Add a simple cli interface.
|
||||
|
||||
## [0.2.0] - 2023-09-09
|
||||
|
||||
### Added
|
||||
- Add a implementation of Caesar cipher.
|
||||
|
||||
## [0.1.0] - 2023-09-09
|
||||
|
||||
### Added
|
||||
- Project initialization.
|
||||
|
||||
[Unreleased]: https://gitlab.com/KKlochko/cipher-analytical-machine/-/compare/0.5.3...main?from_project_id=50218541&straight=false
|
||||
[0.5.3]: https://gitlab.com/KKlochko/cipher-analytical-machine/-/compare/0.5.2...0.5.3?from_project_id=50218541&straight=false
|
||||
[0.5.2]: https://gitlab.com/KKlochko/cipher-analytical-machine/-/compare/0.5.1...0.5.2?from_project_id=50218541&straight=false
|
||||
[0.5.1]: https://gitlab.com/KKlochko/cipher-analytical-machine/-/compare/0.5.0...0.5.1?from_project_id=50218541&straight=false
|
||||
[0.5.0]: https://gitlab.com/KKlochko/cipher-analytical-machine/-/compare/0.4.3...0.5.0?from_project_id=50218541&straight=false
|
||||
[0.4.3]: https://gitlab.com/KKlochko/cipher-analytical-machine/-/compare/0.4.2...0.4.3?from_project_id=50218541&straight=false
|
||||
[0.4.2]: https://gitlab.com/KKlochko/cipher-analytical-machine/-/compare/0.4.1...0.4.2?from_project_id=50218541&straight=false
|
||||
[0.4.1]: https://gitlab.com/KKlochko/cipher-analytical-machine/-/compare/0.4.0...0.4.1?from_project_id=50218541&straight=false
|
||||
[0.4.0]: https://gitlab.com/KKlochko/cipher-analytical-machine/-/compare/0.3.5...0.4.0?from_project_id=50218541&straight=false
|
||||
[0.3.5]: https://gitlab.com/KKlochko/cipher-analytical-machine/-/compare/0.3.4...0.3.5?from_project_id=50218541&straight=false
|
||||
[0.3.4]: https://gitlab.com/KKlochko/cipher-analytical-machine/-/compare/0.3.3...0.3.4?from_project_id=50218541&straight=false
|
||||
[0.3.3]: https://gitlab.com/KKlochko/cipher-analytical-machine/-/compare/0.3.2...0.3.3?from_project_id=50218541&straight=false
|
||||
[0.3.2]: https://gitlab.com/KKlochko/cipher-analytical-machine/-/compare/0.3.1...0.3.2?from_project_id=50218541&straight=false
|
||||
[0.3.1]: https://gitlab.com/KKlochko/cipher-analytical-machine/-/compare/0.3.0...0.3.1?from_project_id=50218541&straight=false
|
||||
[0.3.0]: https://gitlab.com/KKlochko/cipher-analytical-machine/-/compare/0.2.0...0.3.0?from_project_id=50218541&straight=false
|
||||
[0.2.0]: https://gitlab.com/KKlochko/cipher-analytical-machine/-/compare/0.1.0...0.2.0?from_project_id=50218541&straight=false
|
||||
[0.1.0]: https://gitlab.com/KKlochko/cipher-analytical-machine/-/commit/a7a715b94276fc8f46fb6a44139636d27b551599
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
[org.apache.tika/tika-core "1.28.5"]
|
||||
[org.apache.tika/tika-langdetect "1.28.5"]]
|
||||
:main ^:skip-aot cipher-analytical-machine.core
|
||||
:java-source-paths ["src/main/java"]
|
||||
:target-path "target/%s"
|
||||
:profiles {:uberjar {:aot :all
|
||||
:jvm-opts ["-Dclojure.compiler.direct-linking=true"]}})
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
(:require [cipher-analytical-machine.caesar :as caesar]
|
||||
[clojure.string :as cs]
|
||||
[cipher-analytical-machine.cipher-analyzers :as ca])
|
||||
(:import [cipher_analytical_machine.ciphers.caesar Decrypted]
|
||||
[cipher_analytical_machine.analizers.caesar FrequencyAnalyzer])
|
||||
(:gen-class))
|
||||
|
||||
(defn get-all-texts
|
||||
@@ -46,3 +48,12 @@
|
||||
(get-key ciphertext symbols letter-frequences)
|
||||
symbols)))
|
||||
|
||||
(defn frequency-analizer-get-plaintext
|
||||
"Return the plaintext from a ciphertext using simple analizer. The function is case-insensitive."
|
||||
[ciphertext symbols letter-frequences]
|
||||
(let [decrypt (reify Decrypted
|
||||
(decrypt [this message key symbols]
|
||||
(caesar/decrypt-message message key symbols)))]
|
||||
(-> (new FrequencyAnalyzer ciphertext symbols letter-frequences decrypt)
|
||||
.crack)))
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package cipher_analytical_machine.analizers.caesar;
|
||||
|
||||
import cipher_analytical_machine.ciphers.caesar.Decrypted;
|
||||
import java.util.Map;
|
||||
|
||||
public class FrequencyAnalyzer {
|
||||
private String ciphertext;
|
||||
private int key;
|
||||
private String symbols;
|
||||
private Decrypted decryptor;
|
||||
|
||||
public FrequencyAnalyzer(String ciphertext, String symbols, Map<Character, Double> symbol_frequences, Decrypted decryptor) {
|
||||
this.ciphertext = ciphertext;
|
||||
this.key = 1;
|
||||
this.symbols = symbols;
|
||||
this.decryptor = decryptor;
|
||||
}
|
||||
|
||||
public String crack() {
|
||||
return decryptor.decrypt(ciphertext, key, symbols);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package cipher_analytical_machine.ciphers.caesar;
|
||||
|
||||
public interface Decrypted {
|
||||
String decrypt(String message, int key, String symbols);
|
||||
}
|
||||
|
||||
@@ -74,3 +74,13 @@
|
||||
(is (= (cs/lower-case plaintext)
|
||||
(get-plaintext ciphertext symbols frequences))))))
|
||||
|
||||
(deftest frequency-analizer-get-plaintext-test
|
||||
(let [plaintext "abc"
|
||||
ciphertext "bca"
|
||||
key 1
|
||||
symbols "abc"
|
||||
frequences sf/english-letter-frequences]
|
||||
(testing "The ciphertext is 'bca' and key is 1."
|
||||
(is (= plaintext
|
||||
(frequency-analizer-get-plaintext ciphertext symbols frequences))))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user