Root > Reference > All Functions > TEADefaultKey

Function TEADefaultKey

Previous pageReturn to chapter overviewNext page   

Returns pre-initialized default key for TEA.

 

Unit

EEncrypt

 

Syntax

 

Code (Delphi)

function TEADefaultKey: TTEAKey;

 

Return value

Key derived from empty password.

 

Remarks

This function returns the same value as TEADeriveKey('', nil).

 

Unlike TEADeriveKey function, TEADefaultKey does not perform any calculations and simply uses pre-initialized value. Thus, you should use this function to improve performance.

 

Note

Encrypting data with empty password does not mean that data will be unencrypted (e.g. not changed). It will be encrypted, but anyone will be able to decrypt it back, as password is empty. Salt is not needed for the same reason (as password is known).

 

Tip

Since default password is always stored in memory - there is not much meaning to wipe default key (with TEADestroyKey) after using it.

 

Examples

 

Code (Delphi)

var

Key: TTEAKey;

EncryptedText: RawByteString;

S: String;

begin

// Use default key

Key := TEADefaultKey; // - same as TEADeriveKey('', nil);

 

// Encrypt some text with the default key

// (meaning "encrypt some text with empty password")

EncryptedText := TEAEncrypt(Key, 'clear text');

 

// EncryptedText contains encrypted RAW bytes

// Do not output EncryptedText to any place which expects human-readable text

 

// There is no much meaning in wiping key from memory, as it is always present anyway

 

// Debug output

// Encrypted text is RAW bytes, so we need to convert it to something readable

// Encrypted value will be the same for the same text

Edit1.Text := HexEncodeString(EncryptedText);

 

// _____________________________________________

 

// Use default key

Key := TEADefaultKey; // - same as TEADeriveKey('', nil);

 

// Decrypt text back

// Use encrypted RAW binary, not the hex-converted text

S := TEADecrypt(Key, EncryptedText);

 

// There is no much meaning in wiping key from memory, as it is always present anyway

 

// Wipe also all data

SecureFree(EncryptedText);

 

// Now S = 'clear text'

 

// Call SecureFree for all data once you have finished working with it

SecureFree(S);

end;

 

See also




Send feedback... Build date: 2024-12-19
Last edited: 2024-12-19
PRIVACY STATEMENT
The documentation team uses the feedback submitted to improve the EurekaLog documentation. We do not use your e-mail address for any other purpose. We will remove your e-mail address from our system after the issue you are reporting has been resolved. While we are working to resolve this issue, we may send you an e-mail message to request more information about your feedback. After the issues have been addressed, we may send you an email message to let you know that your feedback has been addressed.


Permanent link to this article: https://www.eurekalog.com/help/eurekalog/topic_function_eencrypt_teadefaultkey.php