added dbf-encrypt
This commit is contained in:
parent
fa10f88a60
commit
ceaa5edcc6
2 changed files with 47 additions and 0 deletions
|
@ -4,6 +4,7 @@ type BaseCommand struct {
|
||||||
Help HelpCommand `command:"help" description:"Print this help message"`
|
Help HelpCommand `command:"help" description:"Print this help message"`
|
||||||
|
|
||||||
DecryptDBF DecryptDBFCommand `command:"decrypt-dbf" description:"decrypt dbf-data"`
|
DecryptDBF DecryptDBFCommand `command:"decrypt-dbf" description:"decrypt dbf-data"`
|
||||||
|
EncryptDBF EncryptDBFCommand `command:"encrypt-dbf" description:"encrypt dbf-data"`
|
||||||
DecryptDES DecryptDESCommand `command:"decrypt-des" description:"decrypt des-data"`
|
DecryptDES DecryptDESCommand `command:"decrypt-des" description:"decrypt des-data"`
|
||||||
|
|
||||||
//CodePlugModify
|
//CodePlugModify
|
||||||
|
|
46
commands/dbf-encrypt.go
Normal file
46
commands/dbf-encrypt.go
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
package commands
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"git.cheetah.cat/cheetah/moto-flash-data/motolol/cpe"
|
||||||
|
)
|
||||||
|
|
||||||
|
type EncryptDBFCommand 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 *EncryptDBFCommand) 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
|
||||||
|
}
|
||||||
|
|
||||||
|
decrypted := cpe.EncryptDBFFile(pdata)
|
||||||
|
|
||||||
|
_, err = outputFile.Write(decrypted)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue