简体   繁体   English

在C#中使用.c文件(winform .net)

[英]using .c files in C# (winform .net)

I am using visual studio 2010 my project is that, i want to encrypt text using blowfish algorithm and then add that encrypted data must be saved in my database 我正在使用Visual Studio 2010我的项目是,我想使用河豚算法对文本进行加密,然后添加加密后的数据必须保存在我的数据库中

my blowfish algorthim is in .c file my input must be taken via C# (windows form) and my database is in sql server 2008 我的河豚算法在.c文件中,我的输入必须通过C#(Windows窗体)进行,而我的数据库在sql server 2008中

i just want to known that can i send the text taken via windows form (.net c#) to my .c file and proccess it and get that encrypted data and save that data in sql server via windows form 我只想知道我可以通过Windows窗体(.net c#)将文本发送到我的.c文件并进行处理,并获取加密的数据,然后通过Windows窗体将数据保存在sql服务器中

can this be done please help me out 能做到这一点,请帮帮我

您必须将.c文件编译为DLL,然后可以使用P / Invoke创建与其绑定的C#

One way is to use C++/CLI as intermediary between your C and C# 一种方法是使用C ++ / CLI作为C和C#之间的中介

C# -> C++/CLI -> C C#-> C ++ / CLI-> C

other way is to expose your C functions and use P/Invoke in C#. 另一种方法是公开C函数并在C#中使用P / Invoke。

Yes. 是。 This is called interop and it can be done in various ways. 这称为互操作,可以通过多种方式完成。 One of them is called Pinvoke - you create a DLL that exports the function you want to call from c# and pinvoke will take care of the rest. 其中一个称为Pinvoke-创建一个DLL,该DLL导出要从c#调用的函数,而pinvoke将负责其余的工作。 I suggest you read about it in microsoft's docs. 我建议您在Microsoft的文档中阅读有关它的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM