Last active
August 29, 2015 14:20
-
-
Save berdario/3a2b9e11f0770ff50aeb to your computer and use it in GitHub Desktop.
Take all the possible letter substitutions in a password, and append to it a list of possible years
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import System.Environment (getArgs) | |
import Data.Map (fromList, findWithDefault) | |
import qualified Data.Set as S | |
nub = S.toList . S.fromList | |
applyIf f = (\x flag -> if flag then f x else x) | |
flagCombinations n = sequence $ replicate n [True, False] | |
leet x = nub $ map (zipWith (applyIf substitute) x) $ flagCombinations $ length x | |
substitutions = fromList [('o','0'), ('a','4'), ('s','5')] | |
substitute x = findWithDefault x x substitutions | |
years = [1900..2014] | |
appendYears x = map ((x ++) . show) years | |
transform = concatMap (concatMap appendYears . leet) | |
main = do | |
infile:_ <- getArgs | |
passwords <- fmap lines $ readFile infile | |
putStrLn $ unlines $ transform passwords |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment