locked
convert PHP to VB RRS feed

  • Question

  • User2110873642 posted

    please would somebody help me. i need this tiny code translated to C# or VB. my server doesnt run PHP, and its all i need to get my site working.

    php

    $ascii = bin2hex($stringToHash);

    $dateTime = date("Y:m:d-H:i:s");

    function getDateTime() {

    global $dateTime;

    return $dateTime;

    }

    thanks..

    Saturday, February 2, 2019 12:10 AM

All replies

  • User-943250815 posted

    For bin2hex you can use Convert.ToInt32("<bynary_string>", <fromBase>).ToString("X") where
    <fromBase> can be 2, 8, 10 or 16 and
    ToString("X") translate to Hexadecimal string

    For date("Y:m:d-H:i:s") if you want it as string use Now.ToString("yyyy:MM:dd-HH:mm:ss") this can result in a string date like "2019:04:30-09:14:45" for more info about format types check https://docs.microsoft.com/en-us/dotnet/standard/base-types/formatting-types

    To get current datetime just use "Now"

    I hope this can help you, it´s been along time I do not touch PHP

    Saturday, February 2, 2019 1:31 AM
  • User2110873642 posted

    unfortunately your code sample for bin2hex doesnt work.

    maybe this will help you understand what im trying to translate:

    <?php
        $dateTime = date("Y:m:d-H:i:s");
        
        function getDateTime() {
            global $dateTime;
            return $dateTime;
        }
        
        function createHash($chargetotal, $currency) {
            $storename = "10123456789";
            $sharedSecret = "sharedsecret";
            $stringToHash = $storename . getDateTime() . $chargetotal . $currency . $sharedSecret;
            $ascii = bin2hex($stringToHash);
            return hash('sha256',$ascii);
        }
    ?>

    pleas help..

    Saturday, February 2, 2019 12:47 PM