0

I am looking for a lightweight method of encrypting XML in php that my c# app will then be able to decrypt. It doesn't need to military strength, just enough to deter casual people from viewing the XML contents.

I've seen several methods online but they span 50+ lines of code and I'm trying to keep this nice and simple.

is there no built-in encryption/decryption methods that both php and c# share that require little more than encrypt($string,METHOD,$key) and decrypt($string, METHOD, $key)?

James
  • 656
  • 2
  • 10
  • 24
  • I would probably try a `base64` encode/decode. Then add an arbitrary known string to confuse things for whoever you are protecting from. – B-and-P Sep 24 '14 at 16:16
  • If you want a super simple method, just use a simple xor. – Jonathan Kuhn Sep 24 '14 at 16:17
  • you can try open_ssl_encrypt check this SO solution http://stackoverflow.com/questions/19719294/decrypt-string-in-c-sharp-that-was-encrypted-with-php-openssl-encrypt – bansi Sep 24 '14 at 16:18
  • As Jonathan suggested, XoR is another one i would most deffinitely consider. Just add **salt** - [link](https://www.google.com.ph/search?site=&source=hp&ei=LvAiVJDPCoO6uAS78YAg&q=encryption+salt&oq=encryption+salt&gs_l=mobile-gws-hp.3..0l5.3835.9483.0.10291.17.16.1.8.8.0.601.4698.0j3j6j4j0j2.15.0....0...1c.1.54.mobile-gws-hp..2.15.1663.3.TUjbOSpsPmU) – B-and-P Sep 24 '14 at 16:31
  • Thanks for all the responses so far guys. I'm just surprised (call me lazy) that strong encryption and decryption cannot be performed in popular languages with a simple one-liner and a strong salt? – James Sep 24 '14 at 16:53
  • Try https://github.com/RNCryptor/RNCryptor . What? You are called James **Napier**? No [relation](https://github.com/rnapier)? – Maarten Bodewes Sep 24 '14 at 18:54
  • Hahah, it appears that my long lost brother has created his own encryption wrapper. Cheers bro! – James Sep 24 '14 at 19:30

1 Answers1

0

I recommend PGP, here is how to do it in PHP: Encrypt files using PGP in PHP?

For C# you will likely use the BouncyCastle library.

Community
  • 1
  • 1
RealityDysfunction
  • 2,609
  • 3
  • 26
  • 53