{"id":4158,"date":"2020-05-28T11:18:19","date_gmt":"2020-05-28T11:18:19","guid":{"rendered":"https:\/\/puvox.software\/blog\/?p=4158"},"modified":"2021-11-14T13:45:48","modified_gmt":"2021-11-14T13:45:48","slug":"two-way-encryption-decryption-between-php-and-c-sharp","status":"publish","type":"post","link":"https:\/\/puvox.software\/blog\/two-way-encryption-decryption-between-php-and-c-sharp\/","title":{"rendered":"Two-way Encryption\/Decryption between PHP and C# (sharp)"},"content":{"rendered":"<div class=\"default-content-clss content_4158 type_post \">\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img fetchpriority=\"high\" decoding=\"async\" src=\"https:\/\/puvox.software\/blog\/wp-content\/uploads\/sites\/2\/2020\/05\/encrypt-decrypt.png\" alt=\"\" class=\"wp-image-4159\" width=\"416\" height=\"168\" srcset=\"https:\/\/puvox.software\/blog\/wp-content\/uploads\/sites\/2\/2020\/05\/encrypt-decrypt.png 698w, https:\/\/puvox.software\/blog\/wp-content\/uploads\/sites\/2\/2020\/05\/encrypt-decrypt-300x121.png 300w, https:\/\/puvox.software\/blog\/wp-content\/uploads\/sites\/2\/2020\/05\/encrypt-decrypt-400x162.png 400w\" sizes=\"(max-width: 416px) 100vw, 416px\" \/><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">We have been using some simple approaches to securely transfer messages between <code>PHP<\/code> and <code>C#<\/code> .  We published our method here on github:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/github.com\/ttodua\/useful-php-scripts\/blob\/master\/two-way-encrypt-decrypt-PHP-C_sharp\">https:\/\/github.com\/ttodua\/useful-php-scripts\/blob\/master\/two-way-encrypt-decrypt-PHP-C_sharp<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Note, you can use the code not only between <strong>PHP-C#<\/strong> communication, but also with each other (<strong>PHP-PHP, C#-C#<\/strong>);<\/p>\n\n\n\n<h2 class=\"has-text-align-center wp-block-heading\">Examples:<\/h2>\n\n\n\n<p>You can simple output some string from <strong>PHP<\/strong>:<\/p>\n<p><code>echo EncryptDecrypt::EncryptString ( \"Hello message to C#\", \"mySecretKey123\" );<\/code><\/p>\n<p>and then read it in <strong>C#<\/strong> :<\/p>\n<p><code>Console.WriteLine( EncryptDecrypt::DecryptString ( encryptedStringFromPhp, \"mySecretKey123\" ) );<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Of course, you can do conversely, encrypt message from <strong>C#<\/strong> and send to <strong>PHP<\/strong> .<br><br><em>p.s. If you also need other kind of encrypt solution solely for PHP, check <em><a href=\"https:\/\/goo.gl\/hZJaEB\">this code<\/a><\/em>.<\/em><\/p>\n\n\n\n<p class=\"has-text-align-right wp-block-paragraph\">( <em>Thanks to articles <a href=\"https:\/\/gist.github.com\/odan\/138dbd41a0c5ef43cbf529b03d814d7c\">1<\/a> and <a href=\"https:\/\/github.com\/skotz\/csharp-to-php-encryption\">2<\/a><\/em> )<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<div class=\"default-content-clss excerpt_4158 type_post \"><p>We have been using some simple approaches to securely transfer messages between PHP and C# . We published our method here on github: https:\/\/github.com\/ttodua\/useful-php-scripts\/blob\/master\/two-way-encrypt-decrypt-PHP-C_sharp Note, you can use the code<a class=\"excerpt-read-more\" href=\"https:\/\/puvox.software\/blog\/two-way-encryption-decryption-between-php-and-c-sharp\/\">(Continue Reading)<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":4159,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[17,13],"tags":[],"class_list":["post-4158","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-coding","category-website"],"_links":{"self":[{"href":"https:\/\/puvox.software\/blog\/wp-json\/wp\/v2\/posts\/4158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/puvox.software\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/puvox.software\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/puvox.software\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/puvox.software\/blog\/wp-json\/wp\/v2\/comments?post=4158"}],"version-history":[{"count":0,"href":"https:\/\/puvox.software\/blog\/wp-json\/wp\/v2\/posts\/4158\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/puvox.software\/blog\/wp-json\/wp\/v2\/media\/4159"}],"wp:attachment":[{"href":"https:\/\/puvox.software\/blog\/wp-json\/wp\/v2\/media?parent=4158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/puvox.software\/blog\/wp-json\/wp\/v2\/categories?post=4158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/puvox.software\/blog\/wp-json\/wp\/v2\/tags?post=4158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}