Search code examples
terminalmcrypt

terminal version of mcrypt


I'm trying to use the terminal version of mcrypt but I haven't success...

I writed: mcrypt -a xtea -m ecb -k "qawsedrftgyhujik" test > testresult

where:

  • xtea is the algorithm
  • ecb is the mode
  • qawsedrftgyhujik is the 128bits key
  • test is the source file
  • testresult is the target file

The program gets freeze and I have to abort with ctl+c. Does anyone knows why?


Solution

  • you have to enter your text and press ctrl+d on a new line to terminate the input, then it should work

    edit: the problem is that -k takes multiple arguments (man mcrypt):

    mcrypt [ -dLFubhvrzp ] [-a algorithm] [-c config_file] [-m mode] [-s keysize] [-o keymode] [-k key1 key2 ...]  [-f keyfile] [ filename ...  ]
    

    so if you want to read from the file test, you can use one of these:

    mcrypt -a xtea  -k "qawsedrftgyhujik" -m ecb test > testresult        # option after -k
    cat test | mcrypt -a xtea -m ecb -k "qawsedrftgyhujik" > testresult   # pipe
    mcrypt -a xtea -m ecb -k "qawsedrftgyhujik" < test > testresult       # stdin redirect