Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8655983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:10:01+00:00 2026-06-12T15:10:01+00:00

I need to convert BlowFish Descrypt code in PHP to C#. PHP code (X-Cart),

  • 0

I need to convert BlowFish Descrypt code in PHP to C#.

PHP code (X-Cart),

function mdecrypt($data, $key) {
    $td = mcrypt_module_open(MCRYPT_BLOWFISH, '', MCRYPT_MODE_ECB, '');
    $decrypted_data = mdecrypt_generic($td, func_hex2str($data));

    return $decrypted_data;
}

#
# Convert hex to string
# 
function func_hex2str($str) {
    $ret = "";
    $l = strlen($str);
    for ($i = 0; $i < $l; $i += 2) {
            $ret .= chr(hexdec(substr($str, $i, 2)));
    }     
        echo $ret;

    return $ret;
}

and I tried,

BlowFish algo = new BlowFish("0cb12a77dbb5ee7128ad3aea6154614f");
string details = "138b5a7e2c0e453a"; 

int dLen = details.Length;
string ret = "";
for (int i = 0; i < dLen; i += 2)
{
    ret += (char) Convert.ToInt64(details.Substring(i, 2), 16);
}
details = algo.Decrypt_ECB(ret);
Console.WriteLine(details); 

but It print different result between PHP and C#. (PHP : HELLO, C# : ??q???_^)

Someone give me a hint, he said it might be about ‘Padding’.

but still I don’t get it.

Anybody know what I am doing wrong? please advise me.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:10:03+00:00Added an answer on June 12, 2026 at 3:10 pm

    BCrypt.Net is an open source implementation of the Blowfish encryption algorithm. You can use that source code to see how it’s done I supposed.

    If you need this just for work and Getting Things Done, usage of BCrypt is dead simple:

    string salt = BCryptHelper.GenerateSalt(6);
    var hashedPassword = BCryptHelper.HashPassword("password", salt);
    Console.WriteLine(BCryptHelper.CheckPassword("password", hashedPassword));
    

    You can find the souce code here:

        /// <summary>Hash a password using the OpenBSD bcrypt scheme.</summary>
        /// <exception cref="ArgumentException">Thrown when one or more arguments have unsupported or
        ///                                     illegal values.</exception>
        /// <param name="input">The password to hash.</param>
        /// <param name="salt">    the salt to hash with (perhaps generated using BCrypt.gensalt).</param>
        /// <returns>The hashed password</returns>
        public static string HashPassword(string input, string salt)
        {
            if (input == null)
                throw new ArgumentNullException("input");
    
            if (string.IsNullOrEmpty(salt))
                throw new ArgumentException("Invalid salt", "salt");
    
            // Determinthe starting offset and validate the salt
            int startingOffset;
            char minor = (char)0;
            if (salt[0] != '$' || salt[1] != '2')
                throw new SaltParseException("Invalid salt version");
            if (salt[2] == '$')
                startingOffset = 3;
            else
            {
                minor = salt[2];
                if (minor != 'a' || salt[3] != '$')
                    throw new SaltParseException("Invalid salt revision");
                startingOffset = 4;
            }
    
            // Extract number of rounds
            if (salt[startingOffset + 2] > '$')
                throw new SaltParseException("Missing salt rounds");
    
            // Extract details from salt
            int logRounds = Convert.ToInt32(salt.Substring(startingOffset, 2));
            string extractedSalt = salt.Substring(startingOffset + 3, 22);
    
            byte[] inputBytes = Encoding.UTF8.GetBytes((input + (minor >= 'a' ? "\0" : "")));
            byte[] saltBytes = DecodeBase64(extractedSalt, BCRYPT_SALT_LEN);
    
            BCrypt bCrypt = new BCrypt();
            byte[] hashed = bCrypt.CryptRaw(inputBytes, saltBytes, logRounds);
    
            // Generate result string
            StringBuilder result = new StringBuilder();
            result.Append("$2");
            if (minor >= 'a')
                result.Append(minor);
            result.AppendFormat("${0:00}$", logRounds);
            result.Append(EncodeBase64(saltBytes, saltBytes.Length));
            result.Append(EncodeBase64(hashed, (_BfCryptCiphertext.Length * 4) - 1));
            return result.ToString();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to convert full state name to its official state address code. For
I need to convert a column data into single row with multiple columns Example
I need to convert hierarchical data (AVRO data, which boils down to JSON) into
I Need Convert This Code To .net (C# or VB.net) Please Help Me For
Equivalent to utf8_decode in php I have an string: tópicos I need convert to
I need convert/synthesize MIDI data to audio stream PCM data. What would be an
I need to convert some code compiled with ARMASM to gcc(code sourcery GCC-4.6.2 eabi).
I need convert image to Data URL (embedding Image) in the Win-application for HTML
Need to convert the following code from Ruby to C#. However I'm kind of
I need convert this array data = [ #SHO 0x56, 0x0d, #CMD 0x1, 0x00,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.