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

  • SEARCH
  • Home
  • 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 6386189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:59:34+00:00 2026-05-25T02:59:34+00:00

I am attempting to replicate the encryption method that is already in existence for

  • 0

I am attempting to replicate the encryption method that is already in existence for part of an application that was written in VB.Net, in PHP. The resulting encrypted values must be the same. I don’t have much experience doing encryption and despite my best effort in scouring the web for information my encrypted values do not match. Could someone let me know where I am going wrong in my PHP code?

Here is the .Net process. Unfortunately this method cannot be changed at this time.

Public Class Encrypt


'8 bytes randomly selected for both the Key and the Initialization Vector
'the IV is used to encrypt the first block of text so that any repetitive 
'patterns are not apparent
Private Shared KEY_64() As Byte = {42, 16, 93, 156, 78, 4, 218, 32}
Private Shared IV_64() As Byte = {55, 103, 246, 79, 36, 99, 167, 3}

Public Function EncryptPwd(ByVal value As String) As String
    Try


        Dim cryptoProvider As DESCryptoServiceProvider = _
                New DESCryptoServiceProvider()
        Dim ms As MemoryStream = New MemoryStream()
        Dim cs As CryptoStream = _
            New CryptoStream(ms, cryptoProvider.CreateEncryptor(KEY_64, IV_64), _
                CryptoStreamMode.Write)
        Dim sw As StreamWriter = New StreamWriter(cs)

        sw.Write(value)
        sw.Flush()
        cs.FlushFinalBlock()
        ms.Flush()

        'convert back to a string
        Return Convert.ToBase64String(ms.GetBuffer(), 0, CInt(ms.Length))
    Finally

    End Try
End Function
End Class

Here is my PHP.

<?php

function addpadding($string, $blocksize = 8)
{
    $len = strlen($string);
    $pad = $blocksize - ($len % $blocksize);
    $string .= str_repeat(chr($pad), $pad);
    return $string;
}
    ?>
<form id="form1" name="form1" method="post" action="">
  enter text
  <input name="data" type="text" />
  <input type="hidden" value="op" name="op" />
  <input type="submit" name="Submit" value="Submit" />
</form>
    <?php

if(!isset($_POST['op'])) {

}else {
    $buffer = $_POST['data']; 

    $keyArray=array( 42, 16, 93, 18, 156, 78, 4, 32 );
    $key=null;
    foreach ($keyArray as $element)
        $key.=CHR($element);
    $ivArray=array( 55, 103, 246, 79, 36, 99, 167, 3 );
    $iv=null;
    foreach ($ivArray as $element)
        $iv.=CHR($element);

    echo "Key: " .$key. "<br>";
    echo "IV: " .$iv. "<br>";
    echo "Result: " .base64_encode(mcrypt_cbc(MCRYPT_DES, $key, addpadding($buffer), MCRYPT_ENCRYPT, $iv));
}
?>
  • 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-05-25T02:59:35+00:00Added an answer on May 25, 2026 at 2:59 am

    Looks like a typo

    Private Shared KEY_64() As Byte = {42, 16, 93, 156, 78, 4, 218, 32}
    $keyArray=array( 42, 16, 93, 18, 156, 78, 4, 32 );
    

    try
    $keyArray=array(42, 16, 93, 156, 78, 4, 218, 32);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Attempting to print out a list of values from 2 different variables that are
I am having issues attempting to replicate a chart that has been generated in
I have written a tab based application in Xcode/RestKit and am attempting to use
I'm attempting to replicate the Facebook app's new menu slider. Creating a slider that
I have a function in C++ that I am attempting to replicate in delphi:
Attempting to make a NSObject called 'Person' that will hold the login details for
Im attempting to bind to the output of a method. Now I've seen examples
Attempting to move an uploaded file so that it is saved in the directory,
Just attempting this question I found in a past exam paper so that I
I am attempting to make a Facebook game and trying to replicate a common

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.