>>> I inherited some code that calls a web service that returns an
>>> encrypted string. It gets decrypted into a string and then converted
[quoted text clipped - 48 lines]
>
> Can I return a string of XML data and still have it be encrypted?
Of course. You can encrypt anything you like.
> This is what is happening on the other side:
>
[quoted text clipped - 3 lines]
> bf.Serialize(ms, usersproduct);
> _result = Convert.ToBase64String(ms.GetBuffer());
There's no encryption in there. If there is encryption, it'll be of the
entire result, rather than this particular string. Base64-encoding is not
encryption, neither is piping something through a BinaryFormatter. These
steps are trivial to recognize and reverse for even a casual observer.
> If I change that to use an XML formatter instead, it still comes across
> as encrypted, right?
I suppose so. Since I don't see any encrypting happening, it's hard to tell,
but it's a safe assumption that the encryption doesn't care whether you're
encrypting Base64-encoded BinaryFormatter output or XmlSerializer output.

Signature
J.
RobinS - 24 Feb 2008 19:22 GMT
>>>> I inherited some code that calls a web service that returns an
>>>> encrypted string. It gets decrypted into a string and then converted to
[quoted text clipped - 71 lines]
> you're encrypting Base64-encoded BinaryFormatter output or XmlSerializer
> output.
I think the encryption is happening in the web service that calls the method
that gets the result.
So how do I pass back the result in XML. I assume I don't want to serialize
the structure, because then I have to have the structure on the other side
to deserialize. Is that right?
So could I create a datatable that basically contains [FieldName] and
[Value] and convert it to XML and return it? Would that work? Or is there an
easier way?
Thanks,
RobinS.
Jeroen Mostert - 24 Feb 2008 19:56 GMT
<snip>
>>>>> I want to remove the dependence on knowing the structure, and
>>>>> deserialize it into an XML string that I can parse for fields and
>>>>> values. Is that possible, and how would I go about doing that?
<snip>
> So how do I pass back the result in XML. I assume I don't want to
> serialize the structure, because then I have to have the structure on
> the other side to deserialize. Is that right?
No. Then you'll have XML, which you can process any way you like. You *can*
deserialize that, but (unlike the data you get from BinaryFormatter) you're
not obliged to deserialize it. You *do* have to have some idea of what's in
it before you can meaningfully process it, of course, but you don't need to
have the exact same type as the web service used for serialization.
In particular, it will allow you to define your own struct type and use that
for deserialization. As long as the existing fields are compatible, the
XmlSerializer will ignore any extraneous fields, and missing fields will be
left with their default values. This "loose conversion" can both be greatly
helpful and greatly harmful, because you can't see exactly what's happening.
> So could I create a datatable that basically contains [FieldName] and
> [Value] and convert it to XML and return it? Would that work?
That's another possible approach, yes.

Signature
J.
RobinS - 24 Feb 2008 20:13 GMT
> <snip>
>>>>>> I want to remove the dependence on knowing the structure, and
[quoted text clipped - 24 lines]
>
> That's another possible approach, yes.
Thanks for your help; you've definitely given me enough to go forward on for
now.
RobinS.