From 0faffa20ce4aca4f6331859dea71a53fd460d42d Mon Sep 17 00:00:00 2001 From: Arity-T Date: Tue, 19 Nov 2024 14:37:33 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B3=D1=80=D0=B0=D0=BD=D0=B8=D1=87?= =?UTF-8?q?=D0=B8=D0=BB=20=D1=81=D0=BF=D0=B8=D1=81=D0=BE=D0=BA=20=D0=B4?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=83=D0=BF=D0=BD=D1=8B=D1=85=20=D1=84=D1=83?= =?UTF-8?q?=D0=BD=D0=BA=D1=86=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab3/src/Lib.hs | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/lab3/src/Lib.hs b/lab3/src/Lib.hs index 01c16f9..7df1bd1 100644 --- a/lab3/src/Lib.hs +++ b/lab3/src/Lib.hs @@ -1,12 +1,14 @@ module Lib - -- ( - -- createAlphabetFromText, - -- encryptCaesar, - -- decryptCaesar, - -- textToBits, - -- bitsToText, - -- encodePixel - -- ) + ( + createAlphabetFromText, + encryptCaesar, + decryptCaesar, + textToBits, + bitsToText, + encodePixel, + extractShift, + extractBitsFromImage + ) where import Codec.Picture @@ -48,8 +50,8 @@ textToBits text = VU.fromList $ concatMap charToBits text charToBits :: Char -> [Int] charToBits c = [if testBit (ord c) i then 1 else 0 | i <- [7,6..0]] -intToBits :: Int -> [Int] -intToBits n = [if testBit n i then 1 else 0 | i <- [31,30..0]] +-- intToBits :: Int -> [Int] +-- intToBits n = [if testBit n i then 1 else 0 | i <- [31,30..0]] bitsToText :: VU.Vector Int -> String bitsToText bits @@ -62,12 +64,6 @@ bitsToInt bits = where len = VU.length bits - 1 -setLastBits :: VU.Vector Int -> VU.Vector Int -> VU.Vector Int -setLastBits byte newBits = byte VU.// updates - where - newBitsLastIndex = VU.length newBits - 1 - updates = [(7 - i, newBits VU.! (newBitsLastIndex - i)) | i <- [0..newBitsLastIndex]] - intToWord8 :: Int -> Word8 intToWord8 x = fromIntegral x