Tag: c ++

如何将此C#Rijndael加密转换为PHP?

关于SO已经有一些有用的问题了: Rijndael 256在c#和php之间加密/解密? 用PHP重写Rijndael 256 C#加密代码 Rijndael / AES解密C#到PHP的转换 但是我的特殊情况仍然存在困难。 我尝试了各种方法,但最终得到错误”The IV parameter must be as long as the blocksize”或与结果散列不匹配的文本。 我不明白加密能够解决我做错的事情。 这是php版本: $pass = ‘hello’; $salt = ‘application-salt’; echo Encrypt(‘hello’, ‘application-salt’); function Encrypt($pass, $salt) { $derived = PBKDF1($pass, $salt, 100, 16); $key = bin2hex(substr($derived, 0, 8)); $iv = bin2hex(substr($derived, 8, 8)); return mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $pass, […]

如何将HTTP标头添加到SOAP客户端

如果有可能将HTTP标头添加到soap客户端Web服务调用,有人可以回答我。 浏览互联网后,我发现的唯一的细节是如何添加SOAP标头。 代码如下所示: var client =new MyServiceSoapClient(); //client.AddHttpHeader(“myCustomHeader”,”myValue”);//There’s no such method, it’s just for clearness var res = await client.MyMethod(); 更新: The request should look like this POST https://service.com/Service.asmx HTTP/1.1 Content-Type: text/xml; charset=utf-8 SOAPAction: “http://www.host.com/schemas/Authentication.xsd/Action” Content-Length: 351 MyHeader: “myValue” Expect: 100-continue Accept-Encoding: gzip, deflate Connection: Keep-Alive BodyGoesHere 信封中的标题属性应为空

ValueInjecter和DataTable

我试图弄清楚ValueInjecter,所以我可以在我们自己种植的小ORM中使用它。 由于我应该支持DataRow和DataTable映射,我正在尝试为这种类型实现映射器。 老实说,文档不够好,我想试一试。 也许Omu或这个图书馆的其他一些用户会回答。 这是我的DataRow注入器 public class DataRowInjection: KnownSourceValueInjection { protected override void Inject(DataRow source, object target) { for (var i = 0; i < source.ItemArray.Count(); i++) { //TODO: Read from attributes or target type var activeTarget = target.GetProps().GetByName(source.Table.Columns[i].ToString(), true); if (activeTarget == null) continue; var value = source.ItemArray[i]; if (value == DBNull.Value) continue; activeTarget.SetValue(target, […]

禁用datagridview中的按钮列

我有一个数据网格视图有4列,前两列是combobox列,第三列是文本框列,第四列是按钮列。在表单加载我必须禁用数据网格的整个按钮列,然后我应该选择前三列和保存后,将这三个列保存在数据库中,特定行中的按钮列应该启用。应该通过单击按钮将第一列保存在数据库中。 请帮助我解决这个问题很多天这里是我使用的代码 private void SATAddTemplate_Load(object sender, EventArgs e) { foreach (DataGridViewRow row in datagrdADDTEMP.Rows) { DataGridViewButtonCell btn = (DataGridViewButtonCell)row.Cells[3]; btn.ReadOnly = true; } } private void btnSaveSettings_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in datagrdADDTEMP.Rows) { DataGridViewButtonCell btn = (DataGridViewButtonCell)row.Cells[3]; btn.ReadOnly = false; } }

如何从运行Windows服务调用方法

我使用c#2005创建并启动了Windows服务Service1(使用exe作为MyService.exe)。 我已经包含了一个方法GetMyRandomNumber(),它返回一个随机的double值。 这里的问题是如何使用这个运行服务,我怎么能调用该方法。 我尝试添加MyService.exe的引用并访问该方法 – Service1 s = new Service1(); MessageBox.Show(s.GetMyRandomNumber().ToString()); 但是发现该方法不是从正在运行的服务实例中调用的,即使我停止服务也会执行语句。 有人可以解释我如何从运行服务实例调用该方法。 感谢您分享宝贵的时间。

如何在C#连接字符串中隐藏密码?

我有以下连接字符串: Data Source=Paul-HP\MYDB;Initial Catalog=MyMSDBSQL;Persist Security Info=True;User ID=sa;Password=password (.net webservice)显然可以通过打开app.config文件并查看配置设置来查看。 我需要的是一种让黑客无法看到密码的方法。 但同时,保持可自定义,以便在部署到另一个数据库时可以更改它。

调用基于异步任务的WCF方法是否利用I / O完成端口或线程池线程来调用延续?

我有以下WCF合同: [ServiceContract(Namespace = “http://abc/Services/AdminService”)] public interface IAdminService { [OperationContract] string GetServiceVersion(); // More methods here } GetServiceVersion是一个返回一些字符串的简单方法。 它用作ping来检查服务是否可访问。 现在我想异步调用它,认为它比使用.NET线程在后台调用它更有效。 所以,我为此提出了以下接口: [ServiceContract(Namespace = “http://abc/Services/AdminService”)] public interface IMiniAdminService { [OperationContract(Action = “http://abc/Services/AdminService/IAdminService/GetServiceVersion”, ReplyAction = “http://abc/Services/AdminService/IAdminService/GetServiceVersionResponse”)] Task GetServiceVersionAsync(); } 这使得可以异步调用GetServiceVersion API: var tmp = new ChannelFactory(“AdminServiceClientEndpoint”); var channelFactory = new ChannelFactory(tmp.Endpoint.Binding, tmp.Endpoint.Address); var miniAdminService = channelFactory.CreateChannel(); return miniAdminService.GetServiceVersionAsync().ContinueWith(t […]

运行Windows 8时,SendMessage / SC_MONITORPOWER不会打开监视器

我使用以下代码打开和关闭显示器: [DllImport(“user32.dll”)] static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam); private const int WM_SYSCOMMAND = 0x0112; private const int SC_MONITORPOWER = 0xF170; private const int MonitorTurnOn = -1; private const int MonitorShutoff = 2; //Turn them off SendMessage(f.Handle, WM_SYSCOMMAND, (IntPtr)SC_MONITORPOWER, (IntPtr)MonitorShutoff); //Turn them on SendMessage(f.Handle, WM_SYSCOMMAND, (IntPtr)SC_MONITORPOWER, (IntPtr)MonitorTurnOn); 这曾经按预期工作,但在安装Windows 8之后( 我认为这是原因,因为我看到其他人有同样的问题 )打开屏幕将无法正常工作。 […]

更新面板刷新后运行Javascript

在更新面板刚刚刷新后,如何加载javascript命令(如onload或onclick或其他东西)。

如何从C#ASP.NET网页调用非托管C / C ++代码

我有一个使用C#的ASP.NET网站,我想从非托管的C / C ++ DLL调用函数。 我该怎么做?