Commit a3cbde34 authored by Vicente Parra Hurtado's avatar Vicente Parra Hurtado 💬

Alpha 0.2

parent 1ba1ac9e
jXfabe05rDauNU6ShU3NfZOWslQ/SYNk94Kkd/fyjwB68NOtBdcI1kDo52io2C270wUNFf9vURfZHwN+M3k5WnFHhMneu8JXtr2mgiWRpSSnQrl/oHxP5H7Ph1seUxKsP9IMtFEyVFocS0u8E/3TG6+cTVeom17elW9xq0bF07KhMKpP0G3Oshsk2jEdxtrt6ukYOzMkbjjbUkLz8vrtJHkRDy3jn4FTZ5O9YGcQLUt4Y4egEJ61hsbbPcSe32D2OtmBPKOy4NUKOlWT8EEDyiBG7mbLFzENmub/bsPk2dBO149jjohifDiDd4v1FM6Ucic5e2u8dV4CVz2+SQNRCA==
\ No newline at end of file
slJYMtNyp9ran+dBH95mQljoQwawS+W37GSsIsJ8O1o3xTY4RZUtL9SaBm+pAw4U1IGKBlO1tvE8j5t1N70uawSzjsijeMYlri7fsyr4qYKSVqOq3DY2DLQ61mqnpEnNvyAFw2HqvkU7Z0TLe+lMj6jptiXu67AAKMsYPBah1b5VxC/z+NeB+3A4mUamSFGwmU1abNJ/9aMls+xHrSS2R6lKferTVVepc+7+iqeZLXzxyuPOMlkpV6dl5O6Kz/vv2qH87+EGg68Duny48DME6ihlvNCQo19wRVCkplujA9m26yusutIAH+umNn8SVv/WIE/JHolRdn9+XTGfwKuMxQ==
\ No newline at end of file
ZxBi5HnulQoNdBoF3UuD0OozrVFsRVH/mXyenCpf95JVZhL9ij/xAz9F8rCMS09OJrAXKqweJP+eYFuJfl4Ks3njwX5C+9a+A3XvB7ChndeJ0D156+AN1aSmrr3YZsxkSL3CcG9LQv4WQEoNFpfHshb8euxLrPjceELGsT5SJpUeLC8QpzhUX6TLa0QC3pgMizQ7K30tg6XEX4b1uNU7+Z5C/MU4CeHH0sNyDeQR+5Xe79fT6lXhezZDu8k9kcrwYmAeMIgmhFkh7pv2bHqcSSuXnLjCBiVf5OKP53gmDmQkHipMHmU3dU/+sC8Nu4ns80ey9hrI35m/mb1WjuSnmw==
\ No newline at end of file
ARG04t8SOOUizkskxPDhsimZUDoIH7HZkdyj4BIMz/X/kXWcWWpkoIuI9io5Jjsain4GdtGPt1sHyg4FZ+fjxgyZTeVfHBeOt0/HXrQioKINPdgQvG/FXbM1zJQGQdMIZuqVtIERicq1y9fXl0StdOgFkvaXJctYuLCu8bdrHoJ2BvJmrHaCOLMLJK7U3buskdmFDZ6kfDVa0D5Zr2MOxKtTXibCUCsOAHS2R0HcFdfrWlOjpiiY7colRlSWy6KouyggCIPQOE0496wjgYYSArrvgG/+nTUNmELXlF2OMtyIZJRHcV6OtfmySXjiHCVxVzq6mnUBBW2iBTVL0xJxqA==
\ No newline at end of file
Ph7Pf7BOPx+zPXsfbEp24dEczPeWVSVLnWh+/4hb1kIp9AUEgHhhyIM5UatjWQQ1SJ2osGvOn3VU+gUUOrrThloKf1dhee4wQA4CCUodKFe6Jz45c/uRU3wiKfljqUgA+XbgQFx0i3GePCtU95Z5fqqGxqmn+NgEh8Wqhm+0xEqdqOVrabn2ZdI4Yk/vaCYrfsqQ/2uJ1E0kS5nl4EuGbnlSfQ0g6UcGXSevcrNRkiQFq0CoWQifEqxxmfZl6/Je43IGt980H3jthuVWVm2D6zMYXvRJd4njNVEnCOVPye9niMOkwrpkujxEon6Wj7hQI2LKyqNXCO7gZRhVLL74Uw==
\ No newline at end of file
import NukeBull
import EncrypText
import System.Environment
import Data.Char
import Data.Bits
import Data.Word
import Data.Either
import Data.Maybe
import System.Random
import qualified Data.Text as T
import qualified Data.Text.Encoding as E
import qualified Data.Text.IO as TIO
import Crypto.Cipher.AES (AES256)
import Crypto.Cipher.Types (BlockCipher(..), Cipher(..),IV, makeIV)
import Crypto.Error (throwCryptoError)
import Crypto.Random(getSystemDRG, randomBytesGenerate)
import Crypto.KDF.Scrypt (generate, Parameters(..))
import qualified Data.ByteString as B
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString.Base64 as BS
-- Chose 128/256 Block entrophy text
choseBlock :: Int -> Int
choseBlock n
| n < 128 = 128
| n < 256 = 256
main = do
(comando:_) <- getArgs
putStrLn "================================================================="
putStrLn "===== N N U U K K EEEE BBB U U L L ====="
putStrLn "===== NN N U U K K E B B U U L L ====="
putStrLn "===== N N N U U KK EEE BBB U U L L ====="
putStrLn "===== N NN U U K K E B B U U L L ====="
putStrLn "===== N N UUUU K K EEEE BBB UUUU LLLL LLLL ====="
putStrLn "================================================================="
putStrLn ""
putStrLn ""
case comando of
"keyGen" -> do
(_:fileName10:fileName20:_) <- getArgs
let fileName1 = "Keys/" ++ fileName10
-- Read Password = 384 bytes = 16 vectorIV + 32 AES256 + 16 Cipher Lv.3.1 + 64 RandomGen Lv 3.2 + 256 Cipher Lv.3.3
g <- getStdGen
g <- newStdGen
drg <- getSystemDRG
let passwords = randomBytesString 320 g
B.writeFile fileName1 passwords
putStrLn "Creating vectorIV ---- is OK"
putStrLn "Creating AES256 ---- is OK"
putStrLn "Creating Password Lv. 3.1 ---- is OK"
putStrLn "Creating Password Lv. 3.2 ---- is OK"
putStrLn "Creating Password Lv. 3.3 ---- is OK"
putStrLn "Writing File (384 bytes - 3072 bites) ---- is OK"
"encrypt" -> do
(_:fileName10:fileName20:_) <- getArgs
let fileName1 = "Keys/" ++ fileName10
let fileName2 = "CryptMsg/" ++ fileName20
-- Read Password = 384 bytes = 16 vectorIV + 32 AES256 + 16 Cipher Lv.3.1 + 64 RandomGen Lv 3.2 + 256 Cipher Lv.3.3
source <- B.readFile fileName1
let vectorIV = B.pack ( take 16 $ B.unpack source )
let password = B.pack (take 32 ( drop 16 $ B.unpack source ))
let passwordL31 = B.pack (take 16 ( drop 48 $ B.unpack source ))
let rows = passwordRows $ B.unpack passwordL31
let cols = passwordCols $ B.unpack passwordL31
let pass2 = take 64 ( drop 64 $ B.unpack source )
let pass = take 256 ( drop 320 $ B.unpack source )
putStrLn "Reading Passwords (3072 bites) ---- is OK"
-- Text to crypt
putStrLn "Text to Encrypt ( Maximum number of characters: 255 ) (ASCII 217 ┘ Forbidden)"
--line1 <- getLine
textoOn <- TIO.getLine
-- The 217 ASCII is the end of the text ( Point Control)
--let line = line1 ++ [chr(217)]
g <- getStdGen
g <- newStdGen
--- No more 256 bytes
if T.length (textoOn) > 256
then putStrLn $ " Yours Characters are: " ++ (show(T.length (textoOn))) ++" (Number Maximun of characters are 255) "
else do
putStrLn $ " Yours Characters are: " ++ (show(T.length (textoOn))) ++ ". Thanks for used me"
let bock = choseBlock ( T.length (textoOn))
g <- newStdGen
g <- newStdGen
texto <- encryptext g bock password vectorIV (E.encodeUtf8 textoOn)
-- B.writeFile fileName2 texto
if B.length texto == 256
then do
-- One Block
putStrLn "One Block Lv3 ---- is OK"
let textoMatrix = orderLv3 20 (B.unpack texto) rows cols pass pass2
--let textoMatrix = orderBytes 10 (B.unpack texto) rows cols
let base64 = BS.encode textoMatrix
putStrLn "Encrypting Text ---- is Ok"
putStrLn "Encoding Base64 for Humans ---- is Ok"
B.writeFile fileName2 base64
putStrLn "Writing Encrypted-Base64 Text ---- is OK"
else do
-- Two Block
putStrLn "One Block Lv3 ---- is OK"
putStrLn "Two Blocks Lv3 ---- is OK"
let textoMatrix1 = orderLv3 20 (B.unpack (B.take 256 texto)) rows cols pass pass2
let textoMatrix2 = orderLv3 20 (B.unpack (B.drop 256 texto)) rows cols pass pass2
let textoMatrix = B.concat [textoMatrix1 ,textoMatrix2]
let base64 = BS.encode textoMatrix
putStrLn "Encrypting Text ---- is Ok"
putStrLn "Encoding Base64 for Humans ---- is Ok"
B.writeFile fileName2 base64
putStrLn "Writing Encrypted-Base64 Text ---- is OK"
"decrypt" -> do
(_:fileName10:fileName20:_) <- getArgs
let fileName1 = "Keys/" ++ fileName10
let fileName2 = "CryptMsg/" ++ fileName20
-- Read Password = 384 bytes = 16 vectorIV + 32 AES256 + 16 Cipher Lv.3.1 + 64 RandomGen Lv 3.2 + 256 Cipher Lv.3.3
source <- B.readFile fileName1
let vectorIV = B.pack ( take 16 $ B.unpack source )
let password = B.pack (take 32 ( drop 16 $ B.unpack source ))
let passwordL31 = B.pack (take 16 ( drop 48 $ B.unpack source ))
let rows = passwordRows $ B.unpack passwordL31
let cols = passwordCols $ B.unpack passwordL31
let pass2 = take 64 ( drop 64 $ B.unpack source )
let pass = take 256 ( drop 320 $ B.unpack source )
putStrLn "Reading Passwords (3072 bites) ---- is OK"
-- Decrypt
code <- B.readFile fileName2
putStrLn "Reading Encrypted Text ---- is OK"
let base64 = BS.decodeLenient code
putStrLn "Decodig Encrypted Text ---- is OK"
if B.length base64 == 256
then do
-- One Block
putStrLn "One Block Lv3 ---- is OK"
let textoMatrix = orderLv3Inv 20 (B.unpack base64) rows cols pass pass2
let num = div ((BC.length (textoMatrix))-1) 2
let block = choseBlock ( num )
text <- decryptext password vectorIV textoMatrix block
putStrLn "Decrypting Text---- is OK"
putStrLn $ show (B.take 20 text)
-- The 217 ASCII is the end of the text
let textoInt = B.elemIndex 217 text
--putStrLn $ show (B.take (fromJust textoInt) text)
TIO.putStrLn (E.decodeUtf8(B.take (fromJust textoInt) text))
else do
-- Two Block
putStrLn "One Block Lv3 ---- is OK"
putStrLn "Two Blocks Lv3 ---- is OK"
let textoMatrix1 = (orderLv3Inv 20 (B.unpack (B.take 256 base64)) rows cols pass pass2)
let textoMatrix2 = (orderLv3Inv 20 (B.unpack (B.drop 256 base64)) rows cols pass pass2)
let textoMatrix = B.concat [textoMatrix1 ,textoMatrix2]
putStrLn "Decrypting Lv3 ---- is OK"
let num = div ((BC.length (textoMatrix))-1) 2
let block = choseBlock ( num )
text <- decryptext password vectorIV textoMatrix block
putStrLn "Decrypting Text---- is OK"
-- The 217 ASCII is the end of the text
let textoInt = B.elemIndex 217 text
--putStrLn $ show (B.take (fromJust textoInt) text)
TIO.putStrLn (E.decodeUtf8(B.take (fromJust textoInt) text))
otherwise ->do
putStrLn "First Argument Is Not Valid"
putStrLn "Used: keyGen FilePad Name"
putStrLn "Used: encrypt FilePad(Password) FilePad (Output)"
putStrLn "Used: decrypt FilePad(Password) FilePad (Output)"
ij,Ng2i@B^,h`%W7tJ/
\ No newline at end of file
File added
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment