Home All Groups Group Topic Archive Search About

Encrypt elements in XML file

Author
12 Jul 2006 8:04 AM
GSwan
Hi,

I'd like to be able to encrypt certain elements of an xml file which i use
in one of my applications. I found the following link of the msdn website
which looks exactly like what i want to do however i'm getting problems:

http://msdn2.microsoft.com/en-us/library/ms229746.aspx

The link suggests that this method is used by apps wanting to store
encrypted data between the times that it runs.
The encrypt part works really well, the problems start when i try to
implement the decrypt code provided via the link at the foot of the page. I
always get the exception error "unable to retrieve decryption key".

Has anyone used this code and could give me any ideas as to what i'm doing
wrong. I wondered if it was to do with creating a new RSACryptoProvider when
the program is started which does not match with the first running of the
application (although thats me clutching at straws :) ).

Any help is greatly appreciated.

Grant

Author
12 Jul 2006 8:20 AM
Dominick Baier
maybe this article helps:

http://msdn.microsoft.com/msdnmag/issues/04/11/XMLSignatures/

Show quoteHide quote
> Hi,
>
> I'd like to be able to encrypt certain elements of an xml file which i
> use in one of my applications. I found the following link of the msdn
> website which looks exactly like what i want to do however i'm getting
> problems:
>
> http://msdn2.microsoft.com/en-us/library/ms229746.aspx
>
> The link suggests that this method is used by apps wanting to store
> encrypted data between the times that it runs.
> The encrypt part works really well, the problems start when i try to
> implement the decrypt code provided via the link at the foot of the
> page. I
> always get the exception error "unable to retrieve decryption key".
> Has anyone used this code and could give me any ideas as to what i'm
> doing wrong. I wondered if it was to do with creating a new
> RSACryptoProvider when the program is started which does not match
> with the first running of the application (although thats me clutching
> at straws :) ).
>
> Any help is greatly appreciated.
>
> Grant
>
Author
12 Jul 2006 9:58 AM
GSwan
That article certainly covers a lot of ground which i've yet to completely
get my head around. However i did focus on the XML encryption example section
which seems to outline exactly what i want to do.

I'm new to the cryptography side of thisngs and still have a question
relating to this.
The example sets an RSA variable 'billingKey' to the value returned by the
getBillingKey() method. Hypothetically would the value returned by this
method always be the same or is it random? I ask because i can't help but
feel my initial problem is caused by something like this. As i said before
though, i'm really not confident with cryptography yet.

Thanks for your quick response,

Grant

Show quoteHide quote
"Dominick Baier" wrote:

> maybe this article helps:
>
> http://msdn.microsoft.com/msdnmag/issues/04/11/XMLSignatures/
>
> > Hi,
> >
> > I'd like to be able to encrypt certain elements of an xml file which i
> > use in one of my applications. I found the following link of the msdn
> > website which looks exactly like what i want to do however i'm getting
> > problems:
> >
> > http://msdn2.microsoft.com/en-us/library/ms229746.aspx
> >
> > The link suggests that this method is used by apps wanting to store
> > encrypted data between the times that it runs.
> > The encrypt part works really well, the problems start when i try to
> > implement the decrypt code provided via the link at the foot of the
> > page. I
> > always get the exception error "unable to retrieve decryption key".
> > Has anyone used this code and could give me any ideas as to what i'm
> > doing wrong. I wondered if it was to do with creating a new
> > RSACryptoProvider when the program is started which does not match
> > with the first running of the application (although thats me clutching
> > at straws :) ).
> >
> > Any help is greatly appreciated.
> >
> > Grant
> >
>
>
>