无法在php

时间:2015-04-25 10:00:02

标签: c# php .net com dcom

我已经完成了dll文件的com注册,它显示在注册表中(我在命令提示符下输入regedit后得到的)
如果我使用$obj1 = new COM("Encryptiondll.ClsEncryption");我没有收到任何错误 但是,当我试图访问一个方法(在.net中声明为公共字符串)时,我从我的PHP代码中收到以下错误
Fatal error: Call to undefined method com::Encrypt12() in C:\xampp\htdocs\test1\index.php on line 12
请帮助
下面是我用来构建dll的c#代码:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace Encryptiondll
{
    public class ClsEncryption
    {
       public static void Main(string[] args)
        {
            
        }
       public static string Encrypt12(string plaintext)
        {

            ASCIIEncoding textConverter = new ASCIIEncoding();
            byte[] key = textConverter.GetBytes("2a1c907916add59edffb3a4b");
            byte[] IV = textConverter.GetBytes("00000000");
            byte[] clearData = Encoding.ASCII.GetBytes(plaintext);
            byte[] cipherData = Encrypt1(clearData, key, IV);
            return Convert.ToBase64String(cipherData);
        }
        public static byte[] Encrypt1(byte[] clearData, byte[] Key, byte[] IV)
        {

            MemoryStream ms = new MemoryStream();
            TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
            tdes.Mode = CipherMode.ECB;
            tdes.Padding = PaddingMode.PKCS7;
            ICryptoTransform alg = tdes.CreateEncryptor(Key, IV);
            CryptoStream cs = new CryptoStream(ms, alg, CryptoStreamMode.Write);
            cs.Write(clearData, 0, clearData.Length);
            cs.FlushFinalBlock();
            cs.Close();
            byte[] encryptedData = ms.ToArray();
            return encryptedData;
        }
    }
}

0 个答案:

没有答案