Welcome to the Xceed Community | Help
Community Search  

SetRandomKeyPair

Sort Posts: Previous Next
  •  09-10-2008, 7:16 AM Post no. 15108

    SetRandomKeyPair

    Hi

    I am new to encryption and I am not quite sure how to use TXCeedEncryption with Delphi 7.

    Specifically, I am trying to build and retreive a pair of keys for the RSA Encryption method.

    procedure TForm1.btnMakeKeysClick(Sender: TObject);
      var f: TextFile;
       RSA: DXceedRSAEncryptionMethod;
       seed,v: Olevariant;
    begin
      RSA:= CoXceedRSAEncryptionMethod.Create;
      seed:= null;
      RSA.SetRandomKeyPair(1024,seed);
      xCry.EncryptionMethod:= RSA;

      assignfile(f,'C:\Privkey.txt');
      rewrite(f);
      v:= RSA.Get_Privatekey;
      writeln(f,xCry.ToString(v));
      closefile(F);


      assignfile(f,'C:\Publickey.txt');
      rewrite(f);
      v:= RSA.Get_Publickey;
      writeln(f,xCry.ToString(v));
      closefile(F);

    end;
     

     

    Is this right ?

    I don't think the resulting text-files look like keys. Am I doing something wrong ? 

    René, SSV aps, DK

    Filed under:
  •  09-15-2008, 2:27 PM Post no. 15278 in reply to 15108

    Re: SetRandomKeyPair

    This because you need to encode the keys before saving them to a text file.  What is returned by the SetRandomKeyPair contains non printable characters that are lost when using them as string.

    You can use our Encoding library to accomplish that.  Or you can use the BinaryToHex and HexToBinary methods from the Signer VB sample to accomplish the same.  Remember to undo the encoding when your ready to use the keys again!

    Under VISTA 

    C:\Xceed Component Samples\Xceed Encryption Library 1.1\Samples\Visual Basic 6\Signer

    Under XP

    C:\Program Files\Xceed Components\Xceed Encryption Library 1.1\Samples\Visual Basic 6\Signer

     


    André
    Software Developer and Tech Support
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.