Write a string in a binary file, problem with CAPICOM

  • Thread starter Thread starter Antonio Ruiz =?iso-8859-1?Q?Mart=EDnez?=
  • Start date Start date
A

Antonio Ruiz =?iso-8859-1?Q?Mart=EDnez?=

Hello!

My problem happens when I'm trying to write a string in DER. I'm
using the following code:

signed = SignedData.Sign(Signer, False,
CAPICOM.CAPICOM_ENCODING_TYPE.CAPICOM_ENCODE_BINARY)

in order to get a PKCS#7 in DER. The signed is defined as string.
The problem is that I don't know how I can write this string in a binary

file. I'm using the following code:
Dim oFileStream As System.IO.StreamWriter
Dim fsn As New FileStream("C:\Prueba\Archivo1.txt" & ".p7",
FileMode.Create)
Dim w As New BinaryWriter(fsn)
' Create the writer for data.
Dim i As Integer
For i = 1 To signed.Length
w.Write(signed.Chars(i))
Next
w.Close()
fsn.Close()

But this code raises me an exception.

Can you help me, please?
Thanks in advance,
Regards,
Antonio
 
Hello!

My problem happens when I'm trying to write a string in DER. I'm
using the following code:

signed = SignedData.Sign(Signer, False,
CAPICOM.CAPICOM_ENCODING_TYPE.CAPICOM_ENCODE_BINARY)

in order to get a PKCS#7 in DER. The signed is defined as string.
The problem is that I don't know how I can write this string in a binary

file. I'm using the following code:
Dim oFileStream As System.IO.StreamWriter
Dim fsn As New FileStream("C:\Prueba\Archivo1.txt" & ".p7",
FileMode.Create)
Dim w As New BinaryWriter(fsn)
' Create the writer for data.
Dim i As Integer
For i = 1 To signed.Length
w.Write(signed.Chars(i))
Next
w.Close()
fsn.Close()

But this code raises me an exception.

Can you help me, please?
Thanks in advance,
Regards,
Antonio

User submitted from AEWNET (http://www.aewnet.com/)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top