Hi all,
I am working on the php program to decrypted the password which is encrypted by C#. However, the codes show below could not work. Any ideas?
C# coding: - private static String password = @"abc";
-
private static String saltV = @"123";
-
private static String hashAlgorithm = "SHA1";
-
private static int passwordIterations = 2;
-
private static String iv = @"123456789123456";
-
private static int keySize = 256;
-
-
public static string Encrypt(string text)
-
{
-
byte[] ivBytes = Encoding.ASCII.GetBytes(iv);
-
byte[] saltBytes = Encoding.ASCII.GetBytes(saltV);
-
byte[] textBytes = Encoding.UTF8.GetBytes(text);
-
-
PasswordDeriveBytes key = new PasswordDeriveBytes(
-
password, saltBytes, hashAlgorithm, passwordIterations);
-
-
byte[] keyBytes = key.GetBytes(keySize / 8);
-
-
RijndaelManaged symmetricKey = new RijndaelManaged();
-
symmetricKey.Mode = CipherMode.CBC;
-
-
ICryptoTransform encryptor =symmetricKey.CreateEncryptorkeyBytes, ivBytes);
-
-
MemoryStream memoryStream = new MemoryStream();
-
CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptor, CryptoStreamMode.Write);
-
cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length);
-
cryptoStream.FlushFinalBlock();
-
-
byte[] cipherTextBytes = memoryStream.ToArray();
-
memoryStream.Close();
-
cryptoStream.Close();
-
return Convert.ToBase64String(cipherTextBytes);
-
}
*************** *************** *************** *************** *************** *********
PHP coding: - function decrypt($crytedText) {
-
$key = "abc";
-
$iv = "123456789123456";
-
$text = mcrypt_decrypt(MCRYPT_RIJNDAEL_256,$key,$cryptedText, MCRYPT_MODE_CBC, $iv);
-
echo("<p>".$text);
-
}
0 1241 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Todd Gruben |
last post by:
I am trying to send some encrypted data from a php application to be
decoded in a .Net application. Both apps encode/decode a given string
but generate different encrypted results. Anyone have any idea? Code
to follow:
php====>
<?php
// Designate string to be encrypted
$string = "This is a test";
|
by: Leonardo D'Ippolito |
last post by:
Hi!
I have two .NET win apps that need to communicate on a TCP/IP network.
'App A' must ask 'app B' if it's allowed to do some task, and 'app B'
must authorize or prohibit it.
How can I do this kind of communication in a secure way (protected
from sniffing)? It would be a very simple protocol. Question, and two
possible answers 'yes' or 'no'.
|
by: Li Pang |
last post by:
Hi,
My inbox receives regularly the encrypted emails. I made a small app by
using outlook activeX to read the emails (decrypted by outlook). I just want
to know if outlook application provides a method to tell me that an email was
encrypted, or it was decrypted from an encrypted one, some thing like
IsEncrypted or similar. Anyone can give me a help?
Thank in advance
|
by: Martin |
last post by:
Is there a way to create and encrypted database file?
What do people do when data security is important at the file level? In
other words, you don't want anyone to be able to take the database file (or
files) and extract data from them.
Ideally, I want a file the is absolutely encrypted on disk and that is
decrypted for data access. The problem, obviously, is that this would be a
very costly (cpu time) approach as you couldn't create...
|
by: VBTricks.de.vu Webmaster |
last post by:
Hello,
I'm trying to implement an encrypted communication with a PHP script.
All the basic stuff (HTTP protocoll, base64) is working. The only
problem is that this method works only for the first 8 letters of the
encrypted string, the rest seems to be not decrypted.
I guess, it's the IV-vector. Unfortunately, I have no experience with
encryption:
| |
by: Michael Sperlle |
last post by:
Is it possible? Bestcrypt can supposedly be set up on linux, but it seems
to need changes to the kernel before it can be installed, and I have no
intention of going through whatever hell that would cause.
If I could create a large file that could be encrypted, and maybe add
files to it by appending them and putting in some kind of delimiter
between files, maybe a homemade version of truecrypt could be constructed.
Any idea what it...
|
by: Bernard Dhooghe |
last post by:
The information center writes:
"Encryption Algorithm: The internal encryption algorithm used is RC2
block cipher with padding, the 128-bit secret key is derived from the
password using a MD2 message digest.
"
and also explains how the length of the encrypted column can be
derived.
|
by: MimiMi |
last post by:
I'm trying to decrypt a byte array in java that was encrypted in C#. I don't get any error messages, just a result that's completely not what I was hoping for.
I think I am using the same type of algorithm, initialization vector (IV), mode, padding, key etc, but I just don't get the two languages to "understand each other", or, in other words, I must be missing out on something crucial.
I encrypt a byte array in C# and send over the byte...
|
by: MimiMi |
last post by:
I'm trying to decrypt a byte array in java that was encrypted in C#. I don't get any error messages, just a result that's completely not what I was hoping for.
I think I am using the same type of algorithm, initialization vector (IV), mode, padding, key etc, but I just don't get the two languages to "understand each other", or, in other words, I must be missing out on something crucial.
I encrypt a byte array in C# and send over the byte...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |