func (ec *Cipher) DecryptByteToJSON(data []byte) (jsonMap map[string]interface{}, err error) {
	decrpytedByte, err := ec.DecryptByte(data)
	if err != nil {
		log.Println("descryption fail ", err.Error())
		return
	}
	err = json.Unmarshal(decrpytedByte, &jsonMap)
	if err != nil {
		log.Println("unmarshal fail ", err.Error())
		return
	}
	return
}
DecryptByteToJSON decrypts from []byte to map[string]interface{}
package sha256
import (
	"crypto/aes"
	"crypto/cipher"
	"crypto/rand"
	"crypto/sha256"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"github.com/lf-edge/edge-home-orchestration-go/internal/common/logmgr"
	c "github.com/lf-edge/edge-home-orchestration-go/internal/restinterface/cipher"
)
type Cipher struct {
	passphrase []byte
}
var (
	log = logmgr.GetInstance()
)
func GetCipher(cipherKeyFilePath string) c.IEdgeCipherer {
	sHA256Cipher := new(Cipher)
	passphrase, err := ioutil.ReadFile(cipherKeyFilePath)
	if err != nil {
		sHA256Cipher.passphrase = []byte{}
		log.Println("len :", len(sHA256Cipher.passphrase))
		log.Println("can't read passphrase key from keyFilePath - ", err)
	} else {
		sHA256Cipher.passphrase = passphrase
	}
	return sHA256Cipher
}
func (ec *Cipher) EncryptByte(byteData []byte) (encryptedByte []byte, err error) {
	if len(byteData) == 0 {
		return nil, errors.New("input of encryptbyte is empty")
	}
	hashByte, err := ec.createHashByte()
	if err != nil {
		log.Println(err)
		return nil, err
	}
	block, _ := aes.NewCipher(hashByte)
	gcm, err := cipher.NewGCM(block)
	if err != nil {
		return
	}
	nonce := make([]byte, gcm.NonceSize())
	if _, err = io.ReadFull(rand.Reader, nonce); err != nil {
		return
	}
	encryptedByte = gcm.Seal(nonce, nonce, byteData, nil)
	return
}
func (ec *Cipher) EncryptJSONToByte(jsonMap map[string]interface{}) (encryptedByte []byte, err error) {
	jsonByte, err := json.Marshal(jsonMap)
	if err != nil {
		return
	}
	encryptedByte, err = ec.EncryptByte(jsonByte)
	if err != nil {
		return
	}
	return
}
func (ec *Cipher) DecryptByte(byteData []byte) (decryptedByte []byte, err error) {
	if len(byteData) == 0 {
		return nil, fmt.Errorf("input of DecryptByte is empty")
	}
	hashByte, err := ec.createHashByte()
	if err != nil {
		log.Println(err)
		return
	}
	block, _ := aes.NewCipher(hashByte)
	gcm, err := cipher.NewGCM(block)
	if err != nil {
		return
	}
	nonceSize := gcm.NonceSize()
	nonce, ciphertext := byteData[:nonceSize], byteData[nonceSize:]
	decryptedByte, err = gcm.Open(nil, nonce, ciphertext, nil)
	if err != nil {
		return
	}
	return
}