Note that there are some explanatory texts on larger screens.

plurals
  1. POcast string back to object after encryption or a way of doing this
    primarykey
    data
    text
    <p>I'm currently trying to pass a encrypted message to msmq and have got as far as being able to encrypt some of the fields in the body such as username and password thanks to the following link <a href="https://stackoverflow.com/questions/165808/simple-2-way-encryption-for-c-sharp">Simple insecure two-way &quot;obfuscation&quot; for C#</a></p> <p>See the following code:</p> <pre><code>var simpleAes = new SimpleAES(); var a = new AddToBasketView { Url = simpleAes.EncryptToString(retailerProduct.DeepLink), RetailerProductId = retailerProduct.Id, RetailerId = retailerProduct.RetailerId, Password = simpleAes.EncryptToString((form["Password"])), Username = simpleAes.EncryptToString(form["Username"]) }; a.RetailerProduct = _retailerProductRepository.GetRetailerProduct(a.RetailerProductId); msgQ.Send(a); </code></pre> <p>But what i really want to do is encrypt the whole message.Body</p> <p>so i tried the following</p> <pre><code> msgQ.Send(simpleAes.EncryptToString(a.ToString())); </code></pre> <p>This encrypts the body but when i come to decrypt it my codes expecting an object it fails - i'm not sure how to deal with this.</p> <p>Here is the code i was using when decrypting the username and password:</p> <pre><code> var message = _msgQ.Receive(); // this should be synchronous and block until we receive // Is the message we have an empty message or a message? if (message != null) { #region decrypt paword and username var simpleAes = new SimpleAES(); var addToBasketView = (AddToBasketView)message.Body; addToBasketView.Password = simpleAes.DecryptString(addToBasketView.Password); addToBasketView.Username = simpleAes.DecryptString(addToBasketView.Username); #endregion decrypt paword and username </code></pre> <p>How can i decrypt the (AddToBasketView)message.Body if i have passed it as a string?</p> <p>EDIT:</p> <p>so the problem is that if i encrypt the object aa follows i have to cast it to a string:</p> <pre><code>msgQ.Send(simpleAes.EncryptToString(a.ToString())); </code></pre> <p>when i come to decrypt it i need it to be an object not a string so i can use it i.e. a.url a.password a.retailerid etc....</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload