File tree 2 files changed +14
-3
lines changed
app/src/main/kotlin/me/leon
2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package me.leon.classical
3
3
import me.leon.ext.splitBySpace
4
4
import me.leon.ext.stripAllSpace
5
5
6
+ // https://en.wikipedia.org/wiki/Morse_code
6
7
val DEFAULT_MORSE =
7
8
mapOf (
8
9
' A' to " .-" ,
@@ -42,15 +43,16 @@ val DEFAULT_MORSE =
42
43
' 9' to " ----." ,
43
44
' 0' to " -----" ,
44
45
' .' to " .-.-.-" ,
45
- ' :' to " ... ---" ,
46
+ ' :' to " ---... " ,
46
47
' ,' to " --..--" ,
47
48
' ;' to " -.-.-." ,
48
49
' ?' to " ..--.." ,
49
50
' =' to " -...-" ,
50
51
' \' ' to " .----." ,
51
52
' /' to " -..-." ,
52
53
' !' to " -.-.--" ,
53
- ' -' to " -...-" ,
54
+ ' -' to " -....-" ,
55
+ ' +' to " .-.-." ,
54
56
' _' to " ..--.-" ,
55
57
' "' to " .-..-." ,
56
58
' (' to " -.--." ,
Original file line number Diff line number Diff line change @@ -96,8 +96,17 @@ enum class ClassicalCryptoType(val type: String) : IClassical {
96
96
},
97
97
MORSE (" morse" ) {
98
98
override fun encrypt (raw : String , params : MutableMap <String , String >) = raw.morseEncrypt()
99
+ .replace(" ." ,params[P1 ].takeUnless { it.isNullOrEmpty() }? : " ." )
100
+ .replace(" -" ,params[P2 ].takeUnless { it.isNullOrEmpty() }? : " -" )
99
101
100
- override fun decrypt (raw : String , params : MutableMap <String , String >) = raw.morseDecrypt()
102
+ override fun decrypt (raw : String , params : MutableMap <String , String >) = raw
103
+ .replace(params[P1 ].takeUnless { it.isNullOrEmpty() }? : " ." ," ." )
104
+ .replace(params[P2 ].takeUnless { it.isNullOrEmpty() }? : " -" ," -" )
105
+ .morseDecrypt()
106
+
107
+ override fun paramsCount () = 2
108
+
109
+ override fun paramsHints () = listOf (" default ." , " default -" )
101
110
102
111
override fun isIgnoreSpace () = false
103
112
},
You can’t perform that action at this time.
0 commit comments