i am very stupid and fucked up lol
This commit is contained in:
parent
2876af419e
commit
7e8959363c
50
.vscode/tasks.json
vendored
Normal file
50
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
|
||||
{
|
||||
// Automatically created by phoityne-vscode extension.
|
||||
|
||||
"version": "2.0.0",
|
||||
"presentation": {
|
||||
"reveal": "always",
|
||||
"panel": "new"
|
||||
},
|
||||
"tasks": [
|
||||
{
|
||||
// F7
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"label": "haskell build",
|
||||
"type": "shell",
|
||||
//"command": "cabal configure && cabal build"
|
||||
"command": "stack build"
|
||||
},
|
||||
{
|
||||
// F6
|
||||
"group": "build",
|
||||
"type": "shell",
|
||||
"label": "haskell clean & build",
|
||||
//"command": "cabal clean && cabal configure && cabal build"
|
||||
"command": "stack clean && stack build"
|
||||
//"command": "stack clean ; stack build" // for powershell
|
||||
},
|
||||
{
|
||||
// F8
|
||||
"group": {
|
||||
"kind": "test",
|
||||
"isDefault": true
|
||||
},
|
||||
"type": "shell",
|
||||
"label": "haskell test",
|
||||
//"command": "cabal test"
|
||||
"command": "stack test"
|
||||
},
|
||||
{
|
||||
// F6
|
||||
"isBackground": true,
|
||||
"type": "shell",
|
||||
"label": "haskell watch",
|
||||
"command": "stack build --test --no-run-tests --file-watch"
|
||||
}
|
||||
]
|
||||
}
|
13
src/Main.hs
13
src/Main.hs
@ -9,21 +9,24 @@ import Data.Maybe
|
||||
- Шифр цезаря
|
||||
- Шифр простой замены
|
||||
- Шифр Атбаша
|
||||
- Шифр транспонирования
|
||||
-}
|
||||
|
||||
-- Шифр Атбаша. Простой шифр с заменой алфавита
|
||||
-- Шифр Цезаря. Сдвиг на N символов в X сторону.
|
||||
|
||||
-- Шифр Атбаша. Инверсия алфавита.
|
||||
-- a = e, r=d и т.д.
|
||||
|
||||
atbashEnc :: String -> String
|
||||
atbashEnc input = do
|
||||
let alp = ['a'..'z']
|
||||
let encAlp = "qadewsrgfthuyjkiolpzcxvnbm"
|
||||
let encAlp = reverse alp
|
||||
map (\x -> encAlp !! (fromJust (elemIndex x alp))) input
|
||||
-- Декодер
|
||||
atbashDec :: String -> String
|
||||
atbashDec input = do
|
||||
let alp = ['a'..'z']
|
||||
let encAlp = "qadewsrgfthuyjkiolpzcxvnbm"
|
||||
let encAlp = reverse alp
|
||||
map (\x -> alp !! (fromJust (elemIndex x encAlp))) input
|
||||
|
||||
-- Простейший шифр, просто сдвигает алфавит на 1
|
||||
@ -38,10 +41,10 @@ simpliestDec input =
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
putStrLn "Simpliest encoding, just +1 to each letter:"
|
||||
putStrLn "Простейшее шифрование, просто сдвигаем алфавит:"
|
||||
print (simpliestEnc "abcdefz")
|
||||
print . simpliestDec $ "bcdefg{"
|
||||
putStrLn "atbash Encryption, changing 1 alphabet to another:"
|
||||
putStrLn "Шифр Атбаша, переворот алфавита:"
|
||||
print . atbashEnc $ "test"
|
||||
print . atbashDec $ ( atbashEnc "test" )
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user