Name: echo 'Check my dubs' | sha1sum 2015-06-16 23:51
echo 'Check my dubs' | sha1sum
import Prelude hiding (concat, putStr)
import Data.ByteString (ByteString(..), concat, putStr)
import Data.ByteString.Base64 (encode)
import Data.ByteString.Builder (byteStringHex, toLazyByteString)
import Data.ByteString.Char8 (unpack)
import Data.ByteString.Lazy (toChunks)
import Crypto.Hash.SHA1 (hash)
import System.Entropy (hGetEntropy, openHandle)
import qualified Prelude as Prelude
main :: IO ()
main = do
s <- openHandle
find s 0
find s n = do
e <- hGetEntropy s 16
let h = unpack . concat . toChunks . toLazyByteString . byteStringHex . hash $ e
n' = check h
if (n' > n)
then do
putStr (encode e)
Prelude.putStr " -> "
putStrLn h
find s n'
else
find s n
check :: String -> Int
check (d:u:bs) | d == u = 1 + check (u:bs)
check _ = 1
echo -n 'SaHpN7YXm3Yh1iU0Iz8EWA==' | base64 -d | sha1sum
.yuuko@Scarlet ~/src $ time ./checkem
XaElwBSgorTZ+myfhuXSqA== -> fd71ad931139f716d6f67acc82ebaf7315028408
YFpK8UaxBPsQrrOVQbu+UA== -> ee36a72b196ffe2eee88e8281215f9512bd9eeb4
Sr1O6cVFpjTOZ3HH129gOw== -> bbb5ce4b3e5a6534e5e8c82a73133f1f0420cd54
qAq1ttKuHFKxpAqwNxLs3w== -> eeee31efa5199bd6e4b0fd15ca87a6ada5277ae9
ra5PsSHS+7DNh9C+swaNNA== -> cccccd26ea5ee33d85e7dcc8f1fc65f188d1b386
zq0+lCwOUJt3l9ejmgBLNw== -> dddddd99ab3e690161adb9c0a22157b87df810df
SaHpN7YXm3Yh1iU0Iz8EWA== -> 8888888e454599718741de577c53111a8708b3f5
^C
real 44m40.573s
user 26m0.003s
sys 18m40.773s
concat . toChunks
are probably horrible for performance, among other things). This would probably run well on a GPU but I don't know how to program for those, so for now these septuples will have to do.