Trying to use Embedded Resouces in a Class .NET

6 views
Skip to first unread message

rken...@guardianwp.com

unread,
Aug 18, 2011, 3:09:59 PM8/18/11
to DidiSoft Forum
I have embedded my Private and Public keys files as a embedded file
within my class I am creating. I did this so that the information will
follow the .dll file. The problem I am running into is that when I get
the data out of the resource. I can pull the data into a Stream object
and convert that into a Text object. The problem I am having is that
signedstring method does not like the Stream or the Text object. So I
tried to make a keystore to import my private key and use that. The
problem is that the Keystore importprivatekey is looking for a file
not a string. Any help or guidance would be appreciated. thanks Robert

didisoft

unread,
Aug 18, 2011, 3:43:21 PM8/18/11
to DidiSoft Forum
Hi Robert,

Will it be Ok for you if we implement a SignStream( Stream dataStream,
Stream privateKeyStream, String privateKeyPassword, Stream
outStream) ?
We can add such method in one day.

Cheers,
Peter Kalef
Technical Support
DidiSoft Ltd.

rken...@guardianwp.com

unread,
Aug 18, 2011, 3:48:42 PM8/18/11
to DidiSoft Forum
Hello Peter,

That would be great.

Thanks
Robert

didisoft

unread,
Aug 19, 2011, 8:39:24 AM8/19/11
to DidiSoft Forum
Hi Robert,

Please download an updated evaluation version from http://didisoft.com/pgpnet.zip

Below is an example how to use the new method.
In fact there are two versions of the method, the second one has an
addition parameter for a file name string to be associated with the
encrypted data.

I will paste here only the first variation, pease refer to the CHM or
MSDN style documentation that ships with the library for the other
one, or just drop me a line.

// C#
using System.IO;
using DidiSoft.Pgp;

class EncryptStreamDemo {
public void Demo() {
PGPLib pgp = new PGPLib();

Stream inputStream = File.OpenRead(@"DataFiles
\INPUT.txt");
Stream publicKey = File.OpenRead(@"DataFiles\public.asc");
Stream encryptedStream = File.OpenWrite(@"DataFiles
\OUTPUT.pgp");

bool asciiArmor = true;

pgp.EncryptFile(inputStream, publicKey, encryptedStream,
asciiArmor);
}
}

' VB.NET
Imports System.IO
Imports DidiSoft.Pgp

Class EncryptStreamDemo
Public Sub Demo()
Dim pgp As New PGPLib()

Dim inputStream As Stream = File.OpenRead("DataFiles
\INPUT.txt")
Dim publicKey As Stream = File.OpenRead("DataFiles
\public.asc")
Dim encryptedStream As Stream = File.OpenWrite("DataFiles
\OUTPUT.pgp")

Dim asciiArmor As Boolean = True

pgp.EncryptFile(inputStream, publicKey, encryptedStream,
asciiArmor)
End Sub
End Class

Best Regards,

didisoft

unread,
Aug 19, 2011, 2:24:52 PM8/19/11
to DidiSoft Forum
Hi Robert,

There is a mistake in the pasted examples. Excuse me for this
inconvenience.

Below are is the correct code:

// C#
using System.IO;
using DidiSoft.Pgp;
class EncryptStreamDemo {
public void Demo() {
PGPLib pgp = new PGPLib();

Stream inputStream = File.OpenRead(@"DataFiles
\INPUT.txt");
Stream publicKey = File.OpenRead(@"DataFiles
\public.asc");
Stream encryptedStream = File.OpenWrite(@"DataFiles
\OUTPUT.pgp");
bool asciiArmor = true;

pgp.EncryptStream(inputStream, publicKey, encryptedStream,
asciiArmor);
}
}

' VB.NET
Imports System.IO
Imports DidiSoft.Pgp
Class EncryptStreamDemo
Public Sub Demo()
Dim pgp As New PGPLib()

Dim inputStream As Stream = File.OpenRead("DataFiles
\INPUT.txt")
Dim publicKey As Stream = File.OpenRead("DataFiles
\public.asc")
Dim encryptedStream As Stream = File.OpenWrite("DataFiles
\OUTPUT.pgp")
Dim asciiArmor As Boolean = True

pgp.EncryptStream(inputStream, publicKey, encryptedStream,
asciiArmor)
End Sub
End Class


Kind Regards,
Reply all
Reply to author
Forward
0 new messages