Convert PHP code to C#

Completed Posted 4 years ago Paid on delivery
Completed Paid on delivery

I need the PHP code below converted to C# and can run on UWP.

<?php

if (!isset($argv[3]))

{

echo "Syntax: {$argv[0]} TradeReference BTCAddress UpdateID [debug]\n";

die();

}

// Build data

$tradeID = $argv[1];

$btcAddress = $argv[2];

// Plus one because this update increments the updateID anyway

$updateID = $argv[3] + 1;

$data = json_encode(array('version' => (int)1, 'reference' => $tradeID, 'btcaddress' => $btcAddress, 'updateID' => (int)$updateID));

if (isset($argv[4]) && $argv[4] == 'debug')

echo "Data is {$data}\n";

// Get private key

$fp = fopen("[login to view URL]", "r");

if (!$fp)

die("Could not open private key [login to view URL]\n");

$priv_key = fread($fp, 8192);

fclose($fp);

$pkeyid = openssl_get_privatekey($priv_key);

if (!$pkeyid)

die("Private key not valid");

// compute signature

openssl_sign($data, $signature, $pkeyid, 'sha512');

// free the key from memory

openssl_free_key($pkeyid);

echo base64_encode($signature) . "\n";

?>

Tests:

Private key for all tests:

-----BEGIN RSA PRIVATE KEY-----

MIICXgIBAAKBgQDHikastc8+I81zCg/qWW8dMr8mqvXQ3qbPAmu0RjxoZVI47tvs

kYlFAXOf0sPrhO2nUuooJngnHV0639iTTEYG1vckNaW2R6U5QTdQ5Rq5u+uV3pMk

7w7Vs4n3urQ6jnqt2rTXbC1DNa/PFeAZatbf7ffBBy0IGO0zc128IshYcwIDAQAB

AoGBALTNl2JxTvq4SDW/3VH0fZkQXWH1MM10oeMbB2qO5beWb11FGaOO77nGKfWc

bYgfp5Ogrql4yhBvLAXnxH8bcqqwORtFhlyV68U1y4R+8WxDNh0aevxH8hRS/1X5

031DJm1JlU0E+vStiktN0tC3ebH5hE+1OxbIHSZ+WOWLYX7JAkEA5uigRgKp8ScG

auUijvdOLZIhHWq7y5Wz+nOHUuDw8P7wOTKU34QJAoWEe771p9Pf/GTA/kr0BQnP

QvWUDxGzJwJBAN05C6krwPeryFKrKtjOGJIniIoY72wRnoNcdEEs3HDRhf48YWFo

riRbZylzzzNFy/gmzT6XJQTfktGqq+FZD9UCQGIJaGrxHJgfmpDuAhMzGsUsYtTr

iRox0D1Iqa7dhE693t5aBG010OF6MLqdZA1CXrn5SRtuVVaCSLZEL/2J5UcCQQDA

d3MXucNnN4NPuS/L9HMYJWD7lPoosaORcgyK77bSSNgk+u9WSjbH1uYIAIPSffUZ

bti+jc1dUg5wb+aeZlgJAkEAurrpmpqj5vg087ZngKfFGR5rozDiTsK5DceTV97K

a3Y+Nzl+XWTxDBWk4YPh2ZlKv402hZEfWBYxUDn5ZkH/bw==

-----END RSA PRIVATE KEY-----

Test 1:

=====

Line to sign:

BYPUS6CJE 3CMCRgEm8HVz3DrWaCCid3vAANE42jcEv9 1

Generated signature:

eud5XV/84oMU6FL+aqhKrorlDwN96q27upqHbpyYkwsMHT6PYbONHspv3m4f1zvmi1miE08NUor7kCxNwoJszsoLa7eiKdoL0XtpDCeXTVuDH2MG4ZiNUOvdJ0TD15E3n97r4iKYMfOY6hzANUCmblI/A9n/PyLypdB4xKnVGnk=

Test 2

=====

Line to sign:

BG2UJ7QE7 3CMCRgEm8HVz3DrWaCCid3vAANE42jcEv9 1

Generated signature:

R7vxhZb8vq+VEZ80MyqIPG9wvQ/7ImHGx8PolxDDiTuG8h4WLQkSAen+vEdoq+shbJEyjfSSuu/z+DulyrvwMvAkGUFwEF2CWVEg1ieJd4SOSpCSjBqaJ2kuKExyzM9cRuZFEMhp5GPaO2JbRsyyoBrS4aURhzqHvQciA2wZeho=

Test 3

=====

Line to sign:

BP4VSFKYF 1BittyL1D1AuiZDjKwQVhM7trpZME55uzm 2

Generated signature:

jOUYUyBSk6etRwsP8Cme3reOKxdlUSTw3zHoo3aEvcNJvwHpq+2Tz24wdUqzqNENLca/OOOyQC8R25oCGD3IoHSIhJfDvf5Mv03Ii+panHIuDiD5YV3AfR03DpkmzbFkUAGqVe+Bu2z7x1nFDQkvLfab7+fq8WYQnMt3Vardv/U=

C# Programming PHP

Project ID: #19765880

About the project

18 proposals Remote project Active 4 years ago

Awarded to:

indilo53

Hello, I have something working on UWP without dependencies. Sample results: {"version":1,"reference":"BYPUS6CJE","btcaddress":"3CMCRgEm8HVz3DrWaCCid3vAANE42jcEv9","updateID":2} eud5XV/84oMU6FL+aqhKrorlDwN96q27u More

$133 USD in 0 days
(4 Reviews)
3.7

18 freelancers are bidding on average $150 for this job

Kartoos

hi...i have read the php code and i canc convert this into c# in few hours....thanks for sharing so much detauls including test cases

$88 USD in 1 day
(140 Reviews)
6.9
DevStar925

Hi, Dear Employer! How are you? I am really interested in your project. I have enough experience on python, C/C++, C#, java,My SQL programming. I am 100% sure i can satisfy your requirements perfectly. User-Friendly I More

$140 USD in 7 days
(29 Reviews)
6.6
sopholos

Hi. I'm worked before with signing and encryption. Please clarify what did you want to do in UWP in this project? I think this code better to convert to console application, nothing to do here with UI at all. Maybe you More

$250 USD in 14 days
(27 Reviews)
6.6
KGeorgy

Hello, I am pleasure with your job for Convert PHP code to C#. Thank you for the job posting. It’s a pleasure to meet you. I’d really like to work with you on this one if possible! I do have a couple of questions, but More

$140 USD in 7 days
(43 Reviews)
6.1
deepthi2889

Hi, I am a Full stack developer in Microsoft technologies. I have worked extensively with digital signatures. You can check the reviews in my profile to confirm this. My area of expertise is web application develop More

$250 USD in 1 day
(20 Reviews)
5.4
ankitbagre2000

Hey, employer. I already have read your description carefully. I have 5+ years enough experience in website development. My major skill are HTML5, CSS3, JavaScript, JQuery, Bootstrap, MySQL etc. I am reliable fr More

$145 USD in 3 days
(50 Reviews)
5.7
mdramindz

Hello, Please message me so we can discuss on that. Please view the profile to see more works of mine. Let's discuss so I can provide you more details about me. Waiting for Your Reply soon. Regards, Mousumi

$99 USD in 3 days
(19 Reviews)
5.1
theukwebexpert

Hello there! My name is Chris, I'm a UK based and native English speaking web developer and app expert with 10 years experience building and maintaining complex web apps and websites. I've built and maintained applic More

$250 USD in 7 days
(4 Reviews)
4.4
BestService222

Hi, Nice to meet you. I am very interested and available to do your project. Your required task actually map on my high skill sets. Please give me an opportunity to show my expertise in the same. I would like to More

$140 USD in 3 days
(17 Reviews)
5.4
rp07364

Hi there, I am a PHP developer having more than 4+ years of experience Magento.I am providing services in website design and development in (PHP/WordPress/Codeigniter/Laravel/Joomla/Magento/Drupal) Technaologies. M More

$188 USD in 3 days
(14 Reviews)
4.4
CODEGASMUK

Hi, I'm Gary and I have been programming in different projects platform for the last 10+ years and I have been able to work with up to 600+clients in all these years of my developing. I see you're looking for a python More

$140 USD in 3 days
(10 Reviews)
5.0
tuantag

Hello, I am Tuan, I am from Vietnam. I have many experience years in digital signature! I have created many app for signing. So I can do solve your problem fastest! Contact me if you interested!

$111 USD in 1 day
(0 Reviews)
0.0
yazan314ati

Hi, This is Yazan Ati from Amman, Jordan. Can you please tell me more about your project? If it is based on Microsoft technologies, you will get job done within deadline. For last 14 years of my career I have been wor More

$30 USD in 7 days
(0 Reviews)
0.0