S
S
Sergey2017-09-29 16:11:28
PHP
Sergey, 2017-09-29 16:11:28

How to translate from C# to PHP the byte array signing function?

Hello
There is a ready method in C# for signing an array of bytes using a certificate

public static string SignData(byte[] bytes, X509Certificate2 certificate)
{            
   var contentInfo = new ContentInfo(bytes);
   var signedCms = new SignedCms(contentInfo, true);
   var cmsSigner = new CmsSigner(certificate);
   signedCms.ComputeSignature(cmsSigner);
   var signature = signedCms.Encode();

   return Convert.ToBase64String(signature);
}

Please tell me the translation of this method into PHP

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kovalsky, 2017-09-29
@dmitryKovalskiy

1) This is a task, not a question.
2) C# code won't help you from the word "no way". In PHP, you won't find a direct match for every line. We need to look for the implementation in the context of PHP

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question