EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Decryption Simple StringFailure

Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.
#12462
Posted: 02/17/2010 09:05:45
by Anand Shanmugam (Basic support level)
Joined: 02/17/2010
Posts: 4

I am using Secureblackbox for .NET. I am using OpenPGP decryption for simple string. The output (decrypted string) just returns the first character. I have copied my code below,

SBPGP.TElPGPReader objReader = new SBPGP.TElPGPReader();

SBPGPKeys.TElPGPKeyring objKeyring = new SBPGPKeys.TElPGPKeyring();
objKeyring.Load(null, "C:\\secureblackbox\\private.pgp", true);
objReader.DecryptingKeys = objKeyring;
objReader.Passphrase = "testing";
objReader.KeyPassphrase = "testing";

byte[] byteArray = Encoding.ASCII.GetBytes(textBox1.Text);
System.IO.Stream obj = new System.IO.MemoryStream(byteArray);

System.IO.Stream outStream = new System.IO.MemoryStream();
objReader.OutputStream = outStream;

objReader.DecryptAndVerify(obj, 0);

System.IO.StreamReader objRdr = new System.IO.StreamReader(outStream);

outStream.Position = 0;
textBox1.Text = objRdr.ReadToEnd();

In the textbox it displays only the first character of the original text.
#12464
Posted: 02/17/2010 10:01:21
by Ken Ivanov (EldoS Corp.)

Thank you for contacting us.

What is the length of the outStream after decryption (check the Length property)?
#12465
Posted: 02/17/2010 11:02:26
by Anand Shanmugam (Basic support level)
Joined: 02/17/2010
Posts: 4

The length of the outStream is 1.
#12466
Posted: 02/17/2010 11:05:23
by Ken Ivanov (EldoS Corp.)

And how do you encrypt the source (please show us the code)?
#12467
Posted: 02/17/2010 12:24:15
by Anand Shanmugam (Basic support level)
Joined: 02/17/2010
Posts: 4

Here is the encryption code,

SBPGP.TElPGPWriter objWriter = new SBPGP.TElPGPWriter();
objWriter.EncryptionType = SBPGP.TSBPGPEncryptionType.etPublicKey;

SBPGPKeys.TElPGPPublicKey objPub = new SBPGPKeys.TElPGPPublicKey();
objPub.LoadFromFile("C:\\secureblackbox\\public.pgp");

SBPGPKeys.TElPGPKeyring objKeyring = new SBPGPKeys.TElPGPKeyring();
objKeyring.AddPublicKey(objPub);
objWriter.EncryptingKeys = objKeyring;

byte[] byteArray = Encoding.ASCII.GetBytes(textBox1.Text);
System.IO.Stream sourceStream = new System.IO.MemoryStream(byteArray);
System.IO.MemoryStream outStream = new System.IO.MemoryStream();
objWriter.Armor = true;

objWriter.Encrypt(sourceStream, outStream, 1);

System.IO.StreamReader objRdr = new System.IO.StreamReader(outStream);
outStream.Position = 0;
textBox1.Text = objRdr.ReadToEnd();
#12468
Posted: 02/17/2010 12:26:47
by Anand Shanmugam (Basic support level)
Joined: 02/17/2010
Posts: 4

Encryption Code
objWriter.Encrypt(sourceStream, outStream, 1); [COLOR=red]

This is the bug in the code. I fixed it. Thanks for the support.
Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.

Reply

Statistics

Topic viewed 1822 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!