I have an application page and am trying to save settings for it using an SPPersistedObject. One of the fields I am saving needs to be encrypted and I tried to use SPEncryptedString but I can't get it to work.
Every time I call the UpdateSecureStringValue method to set the SPEncryptedString's SecureString with the value I need to store (after creating a SecureString with it), a SecurityException ("Access denied.") is thrown.
Can anyone tell me what I am doing wrong or possibly point me to some code that works?