Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
benricok committed Oct 28, 2021
1 parent 29ec898 commit 833412a
Show file tree
Hide file tree
Showing 43 changed files with 4,020 additions and 2,851 deletions.
19 changes: 19 additions & 0 deletions Phase 2/Algorithms_u.pas
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@ TCrypto = class(TComponent)

implementation


// -----------------------------------------------------------------------------
//
// Copyright (C) 2021 Benrico Krog
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>
//
// -----------------------------------------------------------------------------

Function TCrypto.hash(sString : string) : string;
begin
// Hash password
Expand Down
9 changes: 6 additions & 3 deletions Phase 2/Help.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ object frmHelp: TfrmHelp
Width = 492
Height = 381
Lines.Strings = (
'# Delphi PAT grade 10'
'1. By Benrico Krog'
'# Delphi PAT grade 11'
'Topic: Encryption and Decryption'
'Algorithm: ELFHashing'
'Created by Benrico Krog'
'Source released under AGPL-3.0 licence'
''
'2. Uses the vigenere algorithm for encryption and decryption'
'3. Topic: Encryption and Decryption.'
''
'## How to use the tool'
'1. Open the endecryptToool.exe application.'
Expand Down
19 changes: 19 additions & 0 deletions Phase 2/Help.pas
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@

// -----------------------------------------------------------------------------
//
// Copyright (C) 2021 Benrico Krog
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>
//
// -----------------------------------------------------------------------------

unit Help;

interface
Expand Down
661 changes: 661 additions & 0 deletions Phase 2/LICENSE

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions Phase 2/Login.pas
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,24 @@ implementation

uses DBUsers_u, Password, Algorithms_u;

// -----------------------------------------------------------------------------
//
// Copyright (C) 2021 Benrico Krog
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>
//
// -----------------------------------------------------------------------------

procedure TfrmLogin.btnLoginClick(Sender: TObject);
Var
sGender : string;
Expand Down
8 changes: 0 additions & 8 deletions Phase 2/Main.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ object frmMain: TfrmMain
object tabDash: TTabSheet
Caption = 'Dashboard'
ImageIndex = 6
ExplicitHeight = 421
object lblUserDash: TLabel
Left = 16
Top = 10
Expand Down Expand Up @@ -291,7 +290,6 @@ object frmMain: TfrmMain
end
object tabReport: TTabSheet
Caption = 'Report'
ExplicitHeight = 421
object lblHeadReport: TLabel
Left = 16
Top = 10
Expand Down Expand Up @@ -425,9 +423,6 @@ object frmMain: TfrmMain
object tabViewReports: TTabSheet
Caption = 'View Reports'
ImageIndex = 3
ExplicitLeft = 8
ExplicitTop = 28
ExplicitHeight = 421
object Label3: TLabel
Left = 16
Top = 10
Expand Down Expand Up @@ -489,7 +484,6 @@ object frmMain: TfrmMain
object tabUserManagement: TTabSheet
Caption = 'User Management'
ImageIndex = 2
ExplicitHeight = 425
object Label1: TLabel
Left = 16
Top = 10
Expand Down Expand Up @@ -789,7 +783,6 @@ object frmMain: TfrmMain
object tabLogs: TTabSheet
Caption = 'Event Logger'
ImageIndex = 5
ExplicitHeight = 421
object Label2: TLabel
Left = 16
Top = 10
Expand Down Expand Up @@ -834,7 +827,6 @@ object frmMain: TfrmMain
object tabLogout: TTabSheet
Caption = 'Logout'
ImageIndex = 4
ExplicitHeight = 421
end
end
object BitBtn1: TBitBtn
Expand Down
25 changes: 25 additions & 0 deletions Phase 2/Main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,25 @@ implementation

uses Login, DBUsers_u, util_u, Password, Help;


// -----------------------------------------------------------------------------
//
// Copyright (C) 2021 Benrico Krog
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warrany of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>
//
// -----------------------------------------------------------------------------

procedure TfrmMain.genUsername(var sUsername: string);
begin
{ | Generate new username and set it to the passed referance varable:
Expand Down Expand Up @@ -293,6 +312,12 @@ procedure TfrmMain.loadUserDash;
'F': rpgGenderDashUser.ItemIndex := 1;
'N': rpgGenderDashUser.ItemIndex := -1;
end;

// Update welcome heading
if username <> 'admin' then
memWelcome.Lines[0] := 'Welcome ' + fullname + ' ' + surname + '!'
else
memWelcome.Lines[0] := 'Welcome admin!';
end;
end;

Expand Down
1 change: 0 additions & 1 deletion Phase 2/Password.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ object frmPassword: TfrmPassword
Anchors = [akLeft, akBottom]
BevelOuter = bvNone
TabOrder = 2
ExplicitTop = 133
object btnPassCancel: TBitBtn
Left = 69
Top = 0
Expand Down
18 changes: 18 additions & 0 deletions Phase 2/Password.pas
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ implementation

uses util_u;

// -----------------------------------------------------------------------------
//
// Copyright (C) 2021 Benrico Krog
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>
//
// -----------------------------------------------------------------------------

procedure TfrmPassword.btnPassCancelClick(Sender: TObject);
begin
state := canceled;
Expand Down
Binary file modified Phase 2/Win32/Debug/Algorithms_u.dcu
Binary file not shown.
Binary file modified Phase 2/Win32/Debug/DBUsers_u.dcu
Binary file not shown.
Binary file modified Phase 2/Win32/Debug/Help.dcu
Binary file not shown.
Binary file modified Phase 2/Win32/Debug/Login.dcu
Binary file not shown.
Binary file modified Phase 2/Win32/Debug/Main.dcu
Binary file not shown.
Binary file modified Phase 2/Win32/Debug/PAT2021_p.exe
Binary file not shown.
Binary file modified Phase 2/Win32/Debug/Password.dcu
Binary file not shown.
Binary file modified Phase 2/Win32/Debug/Users.ldb
Binary file not shown.
7 changes: 7 additions & 0 deletions Phase 2/Win32/Debug/event.log
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,10 @@
2021/10/28 02:56:52;[ Info ];User admin logged in.
2021/10/28 03:00:14;[ Info ];User admin logged in.
2021/10/28 03:04:56;[ Info ];User admin logged in.
2021-10-28 01:04:52 PM;[ Info ];User admin logged in.
2021-10-28 01:06:02 PM;[ Info ];User admin logged in.
2021-10-28 01:08:33 PM;[ Info ];User admin logged in.
2021-10-28 01:10:01 PM;[ Info ];User admin logged in.
2021-10-28 01:34:09 PM;[ Info ];User admin logged in.
2021-10-28 01:35:12 PM;[ Warning ];Invalid password by user admin
2021-10-28 01:35:17 PM;[ Info ];User admin logged in.
Binary file modified Phase 2/Win32/Debug/util_u.dcu
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ type

// Temp test function
Function hash(sString : string) : string;

private
Var
Private
Var
sNewKey : String;

const
// Characters for vigenere algorithm
sAvalibleChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ';
const
// Characters for vigenere algorithm
sAvalibleChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ';
end;

Var
Expand Down Expand Up @@ -127,8 +125,7 @@ begin
//Check if Min value is smaller than Max value
if iMin >= iMax then
MessageDlg('Please enter the minimum and maximum values in correctly',mtError, mbOKCancel, 0)
else
begin
else begin
//Initilize for loop counter
i := 1;

Expand All @@ -153,8 +150,7 @@ begin
MessageDlg('Please select characters for the gererator to use',mtError, mbOKCancel, 0);

//Generate Key
for i := 1 to iLengthKey do
begin
for i := 1 to iLengthKey do begin
sGenKey := sGenKey + sGenAvalible[Randomrange(1, iLengthGenAvalible+1)];
end;

Expand All @@ -174,7 +170,7 @@ begin
end;

//Main decrypt function
function Decrypt(sEncryptedMsg, sKeyIn : string) : string;
function TCrypto.Decrypt(sEncryptedMsg, sKeyIn : string) : string;
Var
sOut{, sB64_encoded, sB64_decoded} : String;
begin
Expand Down Expand Up @@ -205,8 +201,7 @@ begin
sEncryptedMsg := sEncryptedMsg + 'x';

//Encryption
for i := 1 to sMsg.length do
begin
for i := 1 to sMsg.length do begin
if (upCase(sMsg[i]) IN ['A'..'Z', '0'..'9']) then
sEncryptedMsg[i] := sAvalibleChars[((Pos(sMsg[i], sAvalibleChars) + Pos(sNewKey[i], sAvalibleChars)) MOD sAvalibleChars.Length)]
else
Expand All @@ -232,8 +227,7 @@ begin
sDecryptedMsg := sDecryptedMsg + 'x';

//Decryption
for i := 1 to sEncryptedMsg.length do
begin
for i := 1 to sEncryptedMsg.length do begin
if (upCase(sEncryptedMsg[i]) IN ['A'..'Z', '0'..'9']) then
sDecryptedMsg[i] := sAvalibleChars[(((Pos(sEncryptedMsg[i], sAvalibleChars) - Pos(sNewKey[i], sAvalibleChars)) + sAvalibleChars.Length) MOD sAvalibleChars.Length)]
else
Expand All @@ -260,8 +254,7 @@ begin
sNewKeyGen := sNewKeyGen + 'x';

//loop through already genarated key and exstend/shorten it acording to the length of the message
for i := 1 to sMsg.length do
begin
for i := 1 to sMsg.length do begin
if j = sKeyIn.Length then
j := 1;

Expand Down
Loading

0 comments on commit 833412a

Please sign in to comment.