0

Trying to connect to chef api from c# .

documentation says, sign the header with the private pem key

My Collegues working on node js use a library called ursa which lets them sign a string using the method privateEncrypt

what is wierd though is that method is called 'privateEncrypt' , i thought private keys are for decryption.

any opinion on an equivalent in the c# world ? or how to connect to chef api from c#

rene
  • 41,474
  • 78
  • 114
  • 152
Rajat banerjee
  • 1,781
  • 3
  • 17
  • 35

1 Answers1

0

If you want to encrypt something with RSA in C# you could use the RSA class: http://msdn.microsoft.com/en-us/library/system.security.cryptography.rsa(v=vs.110).aspx

Asymmetric cryptography is just a pair of keys for decrypting/encrypting. You just choose one of them to be private and the other one to be public. If you encrypt using one of them the decryption should be done with the other one.

Håkan Fahlstedt
  • 2,040
  • 13
  • 17
  • First of all, thanks Hakan for the reply . The key is a private key inside a pem file . I am not sure if the api wants me to encrypt the data or sign the data (i believe private key's are used for signing ). documentation asks me to sign the data , but the ursa method goes by privateEncrypt. Just to be sure ,i have tried both methods . – Rajat banerjee Jan 22 '14 at 10:16
  • Encrypting and signing are virtually the same thing. Signing means you encrypt known data with a private key. Then everyone, with access to the public key, could verify the signing by decrypting the signed data and verify that it decrypts to the known data. I'm not familiar with the Chef API, so I'm not sure how to help you further. Maybe if you post some of your source code, I might be able to understand what you want to solve. – Håkan Fahlstedt Jan 22 '14 at 10:51