.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

c# deal with openssl (RSA)

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :WPF

Hi there, i'm trying to make an RSA communication between PHP and c# but the generated keys are different between both languages, so:
Is that possible make an RSA communication between c# and php? (i don't want anything about communication, i have it already, i just need to encrypt on PHP and decrypt on c# and vise-versa (using public an private key), nothing else)


Can anyone help me out  : )

View Complete Post

More Related Resource Links

How to deal with NULL values in a SQL table


 Hi all

In order to add/update/delete data from a table I build 2 classes: 1 class containing all the table fields and another class with methods to add/insert/update/delete records. I am learning how to avoid errors when your table must use SQL NULL values. One error is when I call my UPDATE method (see below):

  public void UpdateItem(OcItemConstraintDetails item)
  SqlConnection con = new SqlConnection(connectionString);
  SqlCommand cmd = new SqlCommand("ItemConstraints_Update", con);
  cmd.CommandType = CommandType.StoredProcedure;

  cmd.Parameters.Add(new SqlParameter("@itemConstraintId", SqlDbType.Int, 4));
  cmd.Parameters["@itemConstraintId"].Value = item.ItemConstraintId;

  cmd.Parameters.Add(new SqlParameter("@path", SqlDbType.NVarChar, 150));
  cmd.Parameters["@path"].Value = item.Path;

if you watch the SQL profiler trace you will see that I am passing a value of 'default' ;so that causes me problems.

exec ItemConstraints_Update @itemConstraintId=1,@path=default

With that said, what are the best practices when your SQL table accepts NULL values and when:
- you are passing an empty value to your stored procedure;

How best to deal with a static C Library which is currently 32-bit?

My application is a mix of a number of different executables and DLL's that are both managed and unmanaged code.  One thing everything has in common is the licensing library which is written in C as a static library.  The managed code is gaining access to this static C library via a C++ CLI assembly which links in the library.  I would like to start offering the managed code as a 64-bit app, but I don't know exactly how to overcome the issue with the static C library and the C++ CLI assembly that consumes it...Assuming I port the static C library over so that there is also a 64-bit version, is there any way I can keep the C++ CLI code bit agnostic and link in both the 32-bit and 64-bit, allowing the Windows loader to use the correct one based on the machine it is running on?  If not, how does one go about telling the C++ CLI code to use the 32-bit library when compiling the C++ CLI to target a 32-bit process and 64-bit library when targetting a 64-bit process?Sam

Querystring format to deal with Ampersand(&)

Hi, I use the following string format to navigate between webpages: String.Format(Eval("Hyper") + "?BUSINESSSTREAM={0}&Dealer={1}&LeadID={2}&Companyid={3}&SalesPerson={4}",  Eval("BusinessStream"), Eval("Dealer"),Eval("leadId"),Eval("CompanyID"),Eval("SalesPerson")) However the companyid is a text string and the company may have an "&" in it which I know will truncate the string. I have seen that this can be overcome by using  "UrlEncode" (http://forums.asp.net/p/1206489/2113465.aspx#2113465) However I cant solve the syntax. Any suggestions appeciated. Regards Colin    

What is the deal with ASP.NET Visual C# and Visual Basic

Hey everyone,This is my first post here, and it looks like a great community, with lots of generous help available!I am just delving into ASP.NET and the .NET framework and it appears to be a little daunting at first.What is the deal with having to choose a language for ASP.NET?Isn't ASP.NET already a web server language itself?Can you also choose JavaScript like you could in Classic-ASP?Isn't C# more for offline development anyway?I'm just trying to get a feel here, because this concept appears to be rather new to me! Any help is greatly appreciated!Thanks!!

How to: Deal with UniqueIdentifiers, casting it to Guid in DAL

HelloMy users table has a column which is a unique identifier (basically this has FK relationship with aspnet_users table, of membership) Now I have an AppUser class which maps to my users tableuserid        intuser_aspnet_id  guid In my DAL, I am retreiving a user from the db an want to populate my appUser obj. How do i Convert value retreived to GuidappUsr.UserID = Convert.ToInt32(reader["user_id"]);appUsr.AspNetUserID =  reader["aspnet_user_id"];(There is no convert.ToGuid)How can this be done?appUsr.UserID = Convert.ToInt32(reader["user_id"]);                 appUsr.AspNetUserID = (Guid)reader["aspnet_user_id"];

Client using OpenSSL is not able to connect to Server using SslStream.


I have been trying to get a client written in C++ using OpenSSL 0.9.8a to connect successfully with a server written in C# using the SslStream class in .NET 4.0.  Thus far, I have been not able to get the client to successfully connect and communicate even when my server does not require a client certificate from the client.

I am getting always the following IOException " The handshake failed due to an unexpected packet format. " when i am reaching the AuthenticateAsServe() line in my server.

Any help will be highly appreciated.

Better way to deal with generics?


I have two collections in my program: List<BaseClass> and List<DerivedClass>. I often need to cycle through both collections. It's so tedious to write 2 cycles every time:

foreach (BaseClass obj in baseClassList)
   ; //Do something

foreach (DerivedClass obj in derivedClassList)
   ; //Do exactly the same thing

I thought, since the objects in the second collection are of a derived class, and not just completely unrelated class, there should be some more elegant way to write this piece of code. Also, I'm concerned with performance, of course: I guess creating a 3rd list and copying all the objects from the 1st and 2nd list into the 3rd list doesn't sound like a good idea. Please, help me!

How to deal with the elements in Claims Based form authentication mMembership?


We are migrating from SharePoint 2007 to 2010. We used to use Forms Authentication for our portal and have a custom login.aspx page for authentication. In this login.aspx page code, it detects new user and will automatically create a user in the membership provider.

However, in SharePoint 2010, System.Web.Security.Membership always points to the defaultProvider="i" which is the default membership provider that claims authentication provider forces.

So we are facing a big problem about how to create a user in the membership provider in the new login.aspx page. How can we handle this situation?

Compatibality of EncrytByCert with openssl.



I am developing an application where we keep the client certificates in the MS SQL database. We have some tables with secured data. Our application upon request from a client fetches a data and uses the certificate to encrypt the data using the EncryptByCert command of MS SQL. The clients have the private key for the certificate and should be able to decrypt the data. Our clients are unix based and uses openssl. However when the client tries to decrypt the data it cannot.

May I get some help on why the openssl fails to decrypt the data encrypted by MS SQL using the same certificate.


Help to create control to deal with layered images


Hi guys!

I need to develop a component to display layered images (an stack of images) to compose a single picture. And I'd like control the display of each layer image (turn on/off) with checkboxes. Ex. Imagine a car... each layer displays one part of the car (when all layers are turned on we can see the entire car).

Any idea?



OpenSSL and SslStream

Hello everyone:

I have a question. Is it possible for a client written in OpenSSL (C) to talk with the server written in .NET (C# using SslStream class).

Because afaik, SslStream has methods such as AutheticateAsServer and some others which do all the low level magic for you, but in case of OpenSSL you have to take care of establishing a connection, and exchaging CipherSpec data and all other stuff involved in the handshake and the subsequest data exchanges.

Could you give me some pointers as to how to achieve this kind of interoperability?


AuthenticateAsClient() exception with OpenSSL server

I have a .NET client and an OpenSSL server doing mutual authentication. SslStream.AuthenticateAsClient() throws the exception "A call to SSPI failed, see inner exception" and the inner exception says "The message received was unexpected or badly formatted". An MSDN article says that this can happen if the server's trusted CA list (which is sent to the client during the SSL handshake) doesn't contain the CA that the client cert is using. I'm setting the trusted CA list in the OpenSSL server so that should be valid. The client and server certs were both signed by the same CA which is valid. If I use a .NET server everything works fine. Is there any way to get specific information about what the client doesn't like? Thanks in advance.

How to replace OpenSSL methods with net ones


Following code in PHP is used to sign data. using private key in pem format. 

    $key = openssl_pkey_get_private ( "pemprivatekey", '' );

openssl_sign ("string to sign", $signature, $key);



How to convert it into C# .NET ? Which net methods shoudl be used instead of openssl ones ?


How to convert PHP openssl signing to .net

PHP Code below signs data using PHP OpenSSL module. How to convert it to C# ?
Which methods should used to replace openssl get key and sign methods ?
  $key = openssl_pkey_get_private (
        file_get_contents ( ''my_private_key.pem'',
 )    );

    if (!openssl_sign ("stringtosign", $signature, $key)) {
        trigger_error ("Unable to generate signature", E_USER_ERROR);

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend