package commands import ( "crypto/cipher" "crypto/des" "io" "os" ) type DecryptDESCommand struct { SourceFileName string `long:"src" alias:"i" required:"true" description:"input-filename"` DestFileName string `long:"dest" alias:"o" required:"true" description:"output-filename"` } func (command *DecryptDESCommand) Execute(args []string) error { inputFile, err := os.Open(command.SourceFileName) if err != nil { return err } defer inputFile.Close() outputFile, err := os.Create(command.DestFileName) if err != nil { return err } defer outputFile.Close() inputFileStat, err := inputFile.Stat() if err != nil { return err } pdata := make([]byte, inputFileStat.Size()) _, err = io.ReadFull(inputFile, pdata) if err != nil { return err } block, err := des.NewTripleDESCipher([]byte("HAVNCPSCMTTUNERAIRTRACER")) if err != nil { return err } iv := []byte("VEDKDJSP") decrypter := cipher.NewCBCDecrypter(block, iv) decrypted := make([]byte, len(pdata)) decrypter.CryptBlocks(decrypted, pdata) _, err = outputFile.Write(decrypted) if err != nil { return err } return nil }