Encrypt

<< Click to Display Table of Contents >>

Navigation:  Apollo VCL Components > Apollo VCL Component Reference > TApolloTable > TApolloTable Methods >

Encrypt

Declaration

function Encrypt( cpBuffer : PChar; sPassWord : String;

iLen : Integer ) : PChar;

Description

Encrypt a buffer with a password.

Parameters

cpBuffer: The buffer to encrypt.

sPassword: The password used to encrypt the buffer. If no password is used (nil) the global workarea password is used.

iLen: The length of the string being encrypted.

Return Value

The buffer contents are returned encrypted as a PChar type.

Delphi Example

// Store encrypted data to a character field

with ApTbl do

 begin

 SetPassword( 'FooBar' ); 

 StrPCopy( cpBuffer, Edit1.Text ); 

 Replace( 'CUSTNO', R_CHAR, Encrypt( cpBuffer, #0,

 Length( Edit1.Text )) ); 

end;

 

…or…

 

procedure TForm1.Button1Click(Sender: TObject);

var

 cpVar: PChar; 

 sVal: String; 

 iSize: Integer; 

begin

 iSize := ApTbl.FieldWidth( 'PASSWORD' ); 

 ApTbl.Edit; 

 sVal := ApTbl.Encrypt( PChar(Edit1.Text), 'FooBar', iSize );

 ApTbl.PutBinary( 'PASSWORD', PChar( sVal )); 

 ApTbl.Post; 

end;

C++Builder Example

// Store encrypted data to a character field

ApTbl->SetPassword( "FooBar" );

StrPCopy( cpBuffer, Edit1->Text );

ApTbl->Replace( "CUSTNO", R_CHAR, ApTbl->Encrypt( cpBuffer, #0,

Length( Edit1->Text )) ); 

See Also

Decrypt, DbfEncrypt, GetBinary, PutBinary