login about faq

We are trying to generate an RSA key pair, then encrypt privatekey w/password, then store the encrypted value in a table.

asked Mar 06 '13 at 09:42

chilkat's gravatar image

chilkat ♦♦

encrypt with public key to decrypt, select row, and load the private key use decrypt, setting the usePrivatekey to 1.

Start with a new RSA object to demonstrate that all we

need are the keys previously exported:

my $rsaEncryptor = new chilkat::CkRsa(); $success = $rsaEncryptor->UnlockComponent("ComponentKey"); if ($success != 1) { print "RSA component unlock failed" . "n"; exit; }

Encrypted output is always binary. In this case, we want

to encode the encrypted bytes in a printable string.

Our choices are "hex", "base64", "url", "quoted-printable".


We'll encrypt with the public key and decrypt with the private

key. It's also possible to do the reverse.

$public contains the public key


$usePrivateKey = 0; my $encryptedStr; connectDB();

open the password file

if (open(MYFILE, "c:\public\passwd")) { $line = <myfile>; while ($line ne "") { chomp($line); $id = trim(substr($line,0,48)); $pass = trim(substr($line,48,32)); $encryptedStr = $rsaEncryptor->encryptStringENC($pass,$usePrivateKey); insertDB($id, $encryptedStr); $line = <myfile>; } } else { die("Cannot open the file INPUT"); } close MYFILE; disConnectDB();


answered Mar 08 '13 at 15:22

cdlvj130's gravatar image


Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Mar 06 '13 at 09:42

Seen: 17,148 times

Last updated: Mar 08 '13 at 15:22

powered by OSQA