Skip to content

Commit

Permalink
Merge pull request #88 from 0chain/feature/decrypt-method-cli
Browse files Browse the repository at this point in the history
Cli method for decrypting message
  • Loading branch information
moldis authored Aug 24, 2021
2 parents 3fe7f08 + 7ef7808 commit d0ff906
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions cmd/walletinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,32 @@ import (

"github.com/0chain/gosdk/core/encryption"
"github.com/0chain/gosdk/zboxcore/client"
"github.com/0chain/gosdk/zcncore"
"github.com/0chain/zboxcli/util"

"github.com/0chain/gosdk/zboxcore/sdk"
"github.com/spf13/cobra"
)

var walletDecryptCmd = &cobra.Command{
Use: "decrypt",
Short: "Decrypt text with passphase",
Long: `Decrypt text with passphase`,
Args: cobra.MinimumNArgs(0),
Run: func(cmd *cobra.Command, args []string) {
passphase, _ := cmd.Flags().GetString("passphase")
text, _ := cmd.Flags().GetString("text")

decrypted, err := zcncore.Decrypt(passphase, text)
if err != nil {
fmt.Println(err)
}

fmt.Println(decrypted)
return
},
}

// walletinfo used for getting the wallet info
var walletinfoCmd = &cobra.Command{
Use: "getwallet",
Expand Down Expand Up @@ -70,4 +90,8 @@ func init() {

rootCmd.AddCommand(signCmd)
signCmd.Flags().String("data", "", "give data for signing, Default will be clientID")

rootCmd.AddCommand(walletDecryptCmd)
walletDecryptCmd.Flags().String("passphase", "", "Passphase to decrypt text")
walletDecryptCmd.Flags().String("text", "", "Encrypted text")
}

0 comments on commit d0ff906

Please sign in to comment.