i am very stupid and fucked up lol

This commit is contained in:
lulzette 2021-05-27 20:00:21 +03:00
parent 2876af419e
commit 7e8959363c
2 changed files with 58 additions and 5 deletions

50
.vscode/tasks.json vendored Normal file
View 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"
}
]
}

View File

@ -9,21 +9,24 @@ import Data.Maybe
- Шифр цезаря - Шифр цезаря
- Шифр простой замены - Шифр простой замены
- Шифр Атбаша - Шифр Атбаша
- Шифр транспонирования
-} -}
-- Шифр Атбаша. Простой шифр с заменой алфавита -- Шифр Цезаря. Сдвиг на N символов в X сторону.
-- Шифр Атбаша. Инверсия алфавита.
-- a = e, r=d и т.д. -- a = e, r=d и т.д.
atbashEnc :: String -> String atbashEnc :: String -> String
atbashEnc input = do atbashEnc input = do
let alp = ['a'..'z'] let alp = ['a'..'z']
let encAlp = "qadewsrgfthuyjkiolpzcxvnbm" let encAlp = reverse alp
map (\x -> encAlp !! (fromJust (elemIndex x alp))) input map (\x -> encAlp !! (fromJust (elemIndex x alp))) input
-- Декодер -- Декодер
atbashDec :: String -> String atbashDec :: String -> String
atbashDec input = do atbashDec input = do
let alp = ['a'..'z'] let alp = ['a'..'z']
let encAlp = "qadewsrgfthuyjkiolpzcxvnbm" let encAlp = reverse alp
map (\x -> alp !! (fromJust (elemIndex x encAlp))) input map (\x -> alp !! (fromJust (elemIndex x encAlp))) input
-- Простейший шифр, просто сдвигает алфавит на 1 -- Простейший шифр, просто сдвигает алфавит на 1
@ -38,10 +41,10 @@ simpliestDec input =
main :: IO () main :: IO ()
main = do main = do
putStrLn "Simpliest encoding, just +1 to each letter:" putStrLn "Простейшее шифрование, просто сдвигаем алфавит:"
print (simpliestEnc "abcdefz") print (simpliestEnc "abcdefz")
print . simpliestDec $ "bcdefg{" print . simpliestDec $ "bcdefg{"
putStrLn "atbash Encryption, changing 1 alphabet to another:" putStrLn "Шифр Атбаша, переворот алфавита:"
print . atbashEnc $ "test" print . atbashEnc $ "test"
print . atbashDec $ ( atbashEnc "test" ) print . atbashDec $ ( atbashEnc "test" )