func (b *BasicMessage) Encrypt(provider CryptoProvider) (*EncryptedMessage, error) {
	if b.HBCIMessage == nil {
		return nil, fmt.Errorf("HBCIMessage must be set")
	}
	var messageBytes []byte
	if b.SignatureBegin != nil {
		sigBytes, err := b.SignatureBegin.MarshalHBCI()
		if err != nil {
			return nil, err
		}
		messageBytes = append(messageBytes, sigBytes...)
	}
	for _, segment := range b.HBCIMessage.HBCISegments() {
		if !reflect.ValueOf(segment).IsNil() {
			segBytes, err := segment.MarshalHBCI()
			if err != nil {
				return nil, err
			}
			messageBytes = append(messageBytes, segBytes...)
		}
	}
	if b.SignatureEnd != nil {
		sigEndBytes, err := b.SignatureEnd.MarshalHBCI()
		if err != nil {
			return nil, err
		}
		messageBytes = append(messageBytes, sigEndBytes...)
	}
	encryptedMessage, err := provider.Encrypt(messageBytes)
	if err != nil {
		return nil, err
	}
	encryptionMessage := NewEncryptedMessage(b.Header, b.End, b.hbciVersion)
	encryptionMessage.EncryptionHeader = b.hbciVersion.PinTanEncryptionHeader("", domain.KeyName{})
	provider.WriteEncryptionHeader(encryptionMessage.EncryptionHeader)
	encryptionMessage.EncryptedData = segment.NewEncryptedDataSegment(encryptedMessage)
	return encryptionMessage, nil
}
// Encrypt encrypts the message using the CryptoProvider
Encrypt encrypts the message using the CryptoProvider
// Encrypt encrypts the message using the CryptoProvider
func (b *BasicMessage) Encrypt(provider CryptoProvider) (*EncryptedMessage, error) {
	if b.HBCIMessage == nil {
		return nil, fmt.Errorf("HBCIMessage must be set")
	}
	var messageBytes []byte
	if b.SignatureBegin != nil {
		sigBytes, err := b.SignatureBegin.MarshalHBCI()
		if err != nil {
			return nil, err
		}
		messageBytes = append(messageBytes, sigBytes...)
	}
	for _, segment := range b.HBCIMessage.HBCISegments() {
		if !reflect.ValueOf(segment).IsNil() {
			segBytes, err := segment.MarshalHBCI()
			if err != nil {
				return nil, err
			}
			messageBytes = append(messageBytes, segBytes...)
		}
	}
	if b.SignatureEnd != nil {
		sigEndBytes, err := b.SignatureEnd.MarshalHBCI()
		if err != nil {
			return nil, err
		}
		messageBytes = append(messageBytes, sigEndBytes...)
	}
	encryptedMessage, err := provider.Encrypt(messageBytes)
	if err != nil {
		return nil, err
	}
	encryptionMessage := NewEncryptedMessage(b.Header, b.End, b.hbciVersion)
	encryptionMessage.EncryptionHeader = b.hbciVersion.PinTanEncryptionHeader("", domain.KeyName{})
	provider.WriteEncryptionHeader(encryptionMessage.EncryptionHeader)
	encryptionMessage.EncryptedData = segment.NewEncryptedDataSegment(encryptedMessage)
	return encryptionMessage, nil
}
func ( b * BasicMessage ) Encrypt ( provider CryptoProvider ) ( * EncryptedMessage , error ) { if b . HBCIMessage == nil { return nil , fmt . Errorf ( " " ) } var messageBytes [ ] byte if b . SignatureBegin != nil { sigBytes , err := b . SignatureBegin . MarshalHBCI ( ) if err != nil { return nil , err } messageBytes = append ( messageBytes , sigBytes ... ) } for _ , segment := range b . HBCIMessage . HBCISegments ( ) { if ! reflect . ValueOf ( segment ) . IsNil ( ) { segBytes , err := segment . MarshalHBCI ( ) if err != nil { return nil , err } messageBytes = append ( messageBytes , segBytes ... ) } } if b . SignatureEnd != nil { sigEndBytes , err := b . SignatureEnd . MarshalHBCI ( ) if err != nil { return nil , err } messageBytes = append ( messageBytes , sigEndBytes ... ) } encryptedMessage , err := provider . Encrypt ( messageBytes ) if err != nil { return nil , err } encryptionMessage := NewEncryptedMessage ( b . Header , b . End , b . hbciVersion ) encryptionMessage . EncryptionHeader = b . hbciVersion . PinTanEncryptionHeader ( " " , domain . KeyName { } ) provider . WriteEncryptionHeader ( encryptionMessage . EncryptionHeader ) encryptionMessage . EncryptedData = segment . NewEncryptedDataSegment ( encryptedMessage ) return encryptionMessage , nil }
Encrypt encrypts the message using the CryptoProvider
Encrypt encrypts the message using the CryptoProvider