0

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

my blowfish algorthim is in .c file my input must be taken via C# (windows form) and my database is in 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

can this be done please help me out

M.Sitter
  • 43
  • 4
CHANDRAHAS
  • 637
  • 3
  • 10
  • 19

3 Answers3

2

You'd have to compile the .c file into a DLL, and then you could use P/Invoke to create a C# binding to it

johnluetke
  • 3,393
  • 1
  • 20
  • 25
2

One way is to use C++/CLI as intermediary between your C and C#

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

other way is to expose your C functions and use P/Invoke in C#.

Carlos Quintanilla
  • 12,937
  • 3
  • 22
  • 25
  • The first choice (using C++/CLI) is less portable, since, AFAIK, the only C++/CLI compiler available is Visual Studio's – dario_ramos Aug 18 '11 at 16:34
1

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. I suggest you read about it in microsoft's docs.

Assaf Lavie
  • 73,079
  • 34
  • 148
  • 203