Dec 9, 2019
0
Level 1
C# GetBytes() method PEM/SHA1 signature realization in PHP
I'm trying use this code for generation pem signature but i cant find similar methods in php (LARAVEL) to realization this. I have tried all similar methods in PHP but the results do not meet the requirements.
var bytes = Encoding.UTF8.GetBytes("/articles")
.Concat(new byte[] { 0x00 })
.Concat(Encoding.UTF8.GetBytes("get"))
.Concat(new byte[] { 0x00 })
.Concat(Encoding.UTF8.GetBytes("Accept-Language en-en Authorization Agent 0505"))
.Concat(new byte[] { 0x00 });
File.WriteAllBytes("digest.txt", bytes.ToArray());
openssl dgst -sha1 -sign private.pem digest.txt > signature.txt
var signatureInBytes = File.ReadAllBytes("signature.txt");
var signatureInBase64 = Convert.ToBase64String(signatureInBytes);
Are there any suggestions?
Please or to participate in this conversation.