Ввод смещения и кол-ва бит
This commit is contained in:
@@ -1,28 +1,31 @@
|
|||||||
module Main (main) where
|
module Main (main) where
|
||||||
|
|
||||||
|
import Text.Read (readMaybe)
|
||||||
import Codec.Picture
|
import Codec.Picture
|
||||||
import qualified Data.Vector.Unboxed as VU
|
import qualified Data.Vector.Unboxed as VU
|
||||||
import Lib
|
import Lib
|
||||||
|
|
||||||
|
|
||||||
caesarShift :: Int
|
|
||||||
caesarShift = 66
|
|
||||||
|
|
||||||
bitsPerByte :: Int
|
|
||||||
bitsPerByte = 1
|
|
||||||
|
|
||||||
sourceTextPath :: String
|
|
||||||
sourceTextPath = "resources/biography.txt"
|
|
||||||
sourceImagePath :: String
|
|
||||||
sourceImagePath = "resources/david.bmp"
|
|
||||||
encodedImagePath :: String
|
|
||||||
encodedImagePath = "tmp/david_" ++ show caesarShift ++ ".bmp"
|
|
||||||
decodedTextPath :: String
|
|
||||||
decodedTextPath = "tmp/biography.txt"
|
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
putStrLn $ "Чтение текста из файла \"" ++ sourceTextPath ++ "\""
|
putStrLn "Введите значение сдвига для шифра Цезаря:"
|
||||||
|
inputCaesarShift <- getLine
|
||||||
|
let caesarShift = case readMaybe inputCaesarShift of
|
||||||
|
Just value -> value
|
||||||
|
Nothing -> error "Ожидалось целое число!"
|
||||||
|
|
||||||
|
putStrLn "Введите количество бит для кодирования:"
|
||||||
|
inputBitsPerByte <- getLine
|
||||||
|
let bitsPerByte = case readMaybe inputBitsPerByte of
|
||||||
|
Just value -> value
|
||||||
|
Nothing -> error "Ожидалось целое число!"
|
||||||
|
|
||||||
|
let sourceTextPath = "resources/biography.txt"
|
||||||
|
let sourceImagePath = "resources/david.bmp"
|
||||||
|
let encodedImagePath = "tmp/david_" ++ show caesarShift ++ ".bmp"
|
||||||
|
let decodedTextPath = "tmp/biography.txt"
|
||||||
|
|
||||||
|
putStrLn $ "\nЧтение текста из файла \"" ++ sourceTextPath ++ "\""
|
||||||
inputText <- readFile sourceTextPath
|
inputText <- readFile sourceTextPath
|
||||||
putStrLn $ "10 символов текста: \"" ++ take 10 inputText ++ "\""
|
putStrLn $ "10 символов текста: \"" ++ take 10 inputText ++ "\""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user