Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #42980 |

    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

    Imported from legacy forums. Posted by Rene (had 3703 views)

    User (Old forums)
    Member
    Post count: 23064

    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

     

    Imported from legacy forums. Posted by André (had 4945 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.