Skip to content

Commit 65a5284

Browse files
author
delphidabbler
committed
Remove support for reading and writing encrypted strings in settings
1 parent 4c74dc1 commit 65a5284

File tree

1 file changed

+0
-53
lines changed

1 file changed

+0
-53
lines changed

Src/USettings.pas

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,6 @@ interface
119119
/// regardless of locale.</remarks>
120120
procedure SetDateTime(const Name: string; const Value: TDateTime);
121121

122-
/// <summary>Gets a named encrypted string value from settings and
123-
/// unencrypts it.</summary>
124-
/// <param name="Name">string [in] Name of value.</param>
125-
/// <returns>string. The unencrypted string.</returns>
126-
function GetEncryptedString(const Name: string): string;
127-
128-
/// <summary>Encrypts and records a named string value in settings.
129-
/// </summary>
130-
/// <param name="Name">string [in] Name of value.</param>
131-
/// <param name="Value">string [in] Value to be encrypted and recored.
132-
/// </param>
133-
procedure SetEncryptedString(const Name, Value: string);
134-
135122
/// <summary>Gets a list of related string values from the section.
136123
/// </summary>
137124
/// <param name="CountName">string [in] Name of an integer value that
@@ -234,7 +221,6 @@ implementation
234221
IOUtils,
235222
// Project
236223
UAppInfo,
237-
UEncryptor,
238224
UHexUtils,
239225
UIOUtils,
240226
UStrUtils;
@@ -465,21 +451,6 @@ TIniSettingsSection = class(TIniSettingsBase, ISettingsSection)
465451
/// </remarks>
466452
procedure SetDateTime(const Name: string; const Value: TDateTime);
467453

468-
/// <summary>Gets a named encrypted string value from settings and
469-
/// unencrypts it.</summary>
470-
/// <param name="Name">string [in] Name of value.</param>
471-
/// <returns>string. The unencrypted string.</returns>
472-
/// <remarks>Method of ISettingsSection.</remarks>
473-
function GetEncryptedString(const Name: string): string;
474-
475-
/// <summary>Encrypts and records a named string value in settings.
476-
/// </summary>
477-
/// <param name="Name">string [in] Name of value.</param>
478-
/// <param name="Value">string [in] Value to be encrypted and recored.
479-
/// </param>
480-
/// <remarks>Method of ISettingsSection.</remarks>
481-
procedure SetEncryptedString(const Name, Value: string);
482-
483454
/// <summary>Gets a list of related string values from the section.
484455
/// </summary>
485456
/// <param name="CountName">string [in] Name of an integer value that
@@ -608,17 +579,6 @@ destructor TIniSettingsSection.Destroy;
608579
inherited;
609580
end;
610581

611-
function TIniSettingsSection.GetEncryptedString(const Name: string): string;
612-
var
613-
EncryptedBytes: TBytes; // encrypted value as array of bytes
614-
begin
615-
// NOTE:
616-
// See SetEncryptedString for details of how encrypted values are stored.
617-
if not TryHexToBytes(GetItemValue(Name), EncryptedBytes) then
618-
Exit('');
619-
Result := TEncoding.UTF8.GetString(TEncryptor.Decrypt(EncryptedBytes));
620-
end;
621-
622582
function TIniSettingsSection.GetBoolean(const Name: string;
623583
const Default: Boolean): Boolean;
624584
var
@@ -746,19 +706,6 @@ procedure TIniSettingsSection.SetDateTime(const Name: string;
746706
SetItemValue(Name, FormatDateTime('yyyy"-"mm"-"dd" "hh":"nn":"ss', Value));
747707
end;
748708

749-
procedure TIniSettingsSection.SetEncryptedString(const Name, Value: string);
750-
begin
751-
// NOTE:
752-
// Encrypted values are stored as follows:
753-
// 1: Unicode Value string is converted to an array of UTF-8 encoded bytes
754-
// 2: The UTF-8 byte array is encrypted into another array of bytes
755-
// 3: The encrypted byte array is converted to hexadecimal
756-
// 4: The hexadecimal character string is stored in storage
757-
SetItemValue(
758-
Name, BytesToHex(TEncryptor.Encrypt(TEncoding.UTF8.GetBytes(Value)))
759-
);
760-
end;
761-
762709
procedure TIniSettingsSection.SetFloat(const Name: string; const Value: Double);
763710
begin
764711
SetItemValue(Name, FloatToStr(Value));

0 commit comments

Comments
 (0)