func UnlockFile(filepath string, secretsKeys KeyData) ([]byte, error) {

	encryptedData, err := ioutil.ReadFile(filepath)
	if err != nil {
		return nil, err
	}

	nonce := make([]byte, gitCryptFileHMACLength)
	copy(nonce, encryptedData[gitCryptFileHeaderLength:(gitCryptFileHeaderLength+gitCryptFileHMACLength)])

	decryptedData, err := decryptData(encryptedData, secretsKeys.AES)
	if err != nil {
		return nil, err
	}

	if !validMAC(decryptedData, nonce, secretsKeys.HMAC) {
		return nil, errors.New("HMAC is not valid. The file could be corrupted")
	}

	return decryptedData, nil
}
// UnlockFile return content of the file decrypted by AES from KeyData
UnlockFile return content of the file decrypted by AES from KeyData
// UnlockFile return content of the file decrypted by AES from KeyData
func UnlockFile(filepath string, secretsKeys KeyData) ([]byte, error) {
	encryptedData, err := ioutil.ReadFile(filepath)
	if err != nil {
		return nil, err
	}
	nonce := make([]byte, gitCryptFileHMACLength)
	copy(nonce, encryptedData[gitCryptFileHeaderLength:(gitCryptFileHeaderLength+gitCryptFileHMACLength)])
	decryptedData, err := decryptData(encryptedData, secretsKeys.AES)
	if err != nil {
		return nil, err
	}
	if !validMAC(decryptedData, nonce, secretsKeys.HMAC) {
		return nil, errors.New("HMAC is not valid. The file could be corrupted")
	}
	return decryptedData, nil
}
func UnlockFile ( filepath string , secretsKeys KeyData ) ( [ ] byte , error ) { encryptedData , err := ioutil . ReadFile ( filepath ) if err != nil { return nil , err } nonce := make ( [ ] byte , gitCryptFileHMACLength ) copy ( nonce , encryptedData [ gitCryptFileHeaderLength : ( gitCryptFileHeaderLength + gitCryptFileHMACLength ) ] ) decryptedData , err := decryptData ( encryptedData , secretsKeys . AES ) if err != nil { return nil , err } if ! validMAC ( decryptedData , nonce , secretsKeys . HMAC ) { return nil , errors . New ( " " ) } return decryptedData , nil }
UnlockFile return content of the file decrypted by AES from KeyData
UnlockFile return content of the file decrypted by AES from KeyData