From 18510679bbfe52a2d2fb489195ed74bf630c57ed Mon Sep 17 00:00:00 2001 From: Mohaimen Hasan Date: Mon, 16 Nov 2026 15:20:15 +0600 Subject: [PATCH] cipher engine --- HRM.BO/User/Role.cs | 7 +++ .../src/app/_services/auth/auth.service.ts | 3 + .../authentication-routing.module.ts | 2 + .../authentication/authentication.module.ts | 4 +- .../cipher-engine.component.html | 34 +++++++++++ .../cipher-engine.component.scss | 61 +++++++++++++++++++ .../cipher-engine/cipher-engine.component.ts | 61 +++++++++++++++++++ .../ClientApp/src/app/kendo-icons.module.ts | 8 ++- HRM.UI/Controllers/Auth/AuthController.cs | 20 ++++++ HRM.UI/appsettings.json | 4 +- 10 files changed, 199 insertions(+), 5 deletions(-) create mode 100644 HRM.UI/ClientApp/src/app/authentication/cipher-engine/cipher-engine.component.html create mode 100644 HRM.UI/ClientApp/src/app/authentication/cipher-engine/cipher-engine.component.scss create mode 100644 HRM.UI/ClientApp/src/app/authentication/cipher-engine/cipher-engine.component.ts diff --git a/HRM.BO/User/Role.cs b/HRM.BO/User/Role.cs index 5c48a2a..82fe98b 100644 --- a/HRM.BO/User/Role.cs +++ b/HRM.BO/User/Role.cs @@ -401,6 +401,13 @@ namespace HRM.BO routerLink = "/authentication/system-auditlog", icon = "pi pi-fw pi-database", }, + new WebMenuItem() + { + uniqueName = "WEB.01.09", + label = "Cipher Engine", + routerLink = "/authentication/cipher-engine", + icon = "pi pi-fw pi-code", + }, } }, diff --git a/HRM.UI/ClientApp/src/app/_services/auth/auth.service.ts b/HRM.UI/ClientApp/src/app/_services/auth/auth.service.ts index 56990b7..c179a57 100644 --- a/HRM.UI/ClientApp/src/app/_services/auth/auth.service.ts +++ b/HRM.UI/ClientApp/src/app/_services/auth/auth.service.ts @@ -297,4 +297,7 @@ export class AuthService { getIsFromUser(): boolean { return this.isFromUserSubject.value; } + CipherMechanism(userData: any) { + return this.apiService.httpPost('/Authentication/CipherMechanism', userData); + } } diff --git a/HRM.UI/ClientApp/src/app/authentication/authentication-routing.module.ts b/HRM.UI/ClientApp/src/app/authentication/authentication-routing.module.ts index b105506..bc500ba 100644 --- a/HRM.UI/ClientApp/src/app/authentication/authentication-routing.module.ts +++ b/HRM.UI/ClientApp/src/app/authentication/authentication-routing.module.ts @@ -10,6 +10,7 @@ import { UserAccessTypeComponent } from './user-access-type/user-access-type.com import {ChangePasswordComponent} from './change-password/change-password.component'; import { DataPermssionComponent } from './data-permssion/data-permssion.component'; import { SystemAuditTrailComponent } from './system-audittrail/system.audittrail.component'; +import { CipherEngineComponent } from './cipher-engine/cipher-engine.component'; @@ -22,6 +23,7 @@ export const routes: Routes = [ { path: 'change-password', component: ChangePasswordComponent, canActivate: [AuthGuard] }, { path: 'data-permssion', component: DataPermssionComponent, canActivate: [AuthGuard] }, { path: 'system-auditlog', component: SystemAuditTrailComponent, canActivate: [AuthGuard] }, + { path: 'cipher-engine', component: CipherEngineComponent, canActivate: [AuthGuard] }, ]; diff --git a/HRM.UI/ClientApp/src/app/authentication/authentication.module.ts b/HRM.UI/ClientApp/src/app/authentication/authentication.module.ts index 27e348b..fd1751d 100644 --- a/HRM.UI/ClientApp/src/app/authentication/authentication.module.ts +++ b/HRM.UI/ClientApp/src/app/authentication/authentication.module.ts @@ -110,6 +110,7 @@ import { KENDO_TREEVIEW } from '@progress/kendo-angular-treeview'; import { LayoutModule } from '@progress/kendo-angular-layout'; import { ExcelExportModule } from '@progress/kendo-angular-excel-export'; import { SystemAuditTrailComponent } from './system-audittrail/system.audittrail.component'; +import { CipherEngineComponent } from './cipher-engine/cipher-engine.component'; @NgModule({ @@ -225,7 +226,8 @@ import { SystemAuditTrailComponent } from './system-audittrail/system.audittrail ChangePasswordComponent, UserComponent, DataPermssionComponent, - SystemAuditTrailComponent + SystemAuditTrailComponent, + CipherEngineComponent ], providers: [ AppWindowPopUp, diff --git a/HRM.UI/ClientApp/src/app/authentication/cipher-engine/cipher-engine.component.html b/HRM.UI/ClientApp/src/app/authentication/cipher-engine/cipher-engine.component.html new file mode 100644 index 0000000..20710c2 --- /dev/null +++ b/HRM.UI/ClientApp/src/app/authentication/cipher-engine/cipher-engine.component.html @@ -0,0 +1,34 @@ + + +
+
+
+ + +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ + +
+
+
\ No newline at end of file diff --git a/HRM.UI/ClientApp/src/app/authentication/cipher-engine/cipher-engine.component.scss b/HRM.UI/ClientApp/src/app/authentication/cipher-engine/cipher-engine.component.scss new file mode 100644 index 0000000..8d6ab25 --- /dev/null +++ b/HRM.UI/ClientApp/src/app/authentication/cipher-engine/cipher-engine.component.scss @@ -0,0 +1,61 @@ +.textarea-wrapper { + position: relative; + width: 100%; +} +textarea.encryptTextArea { + font-size: 1rem; + padding: 0.75rem 2.5rem 0.75rem 0.75rem; + border-radius: 0.5rem; + resize: none; + width: 100%; + height: 78%; + box-sizing: border-box; +} +textarea.decryptTextArea { + font-size: 1rem; + padding: 0.75rem 2.5rem 0.75rem 0.75rem; + border-radius: 0.5rem; + resize: none; + width: 100%; + height: 78%; + box-sizing: border-box; + font-weight: bold; +} +.clear-btn { + position: absolute; + right: 10px; + top: 50%; + transform: translateY(-50%); + background: transparent; + border: none; + cursor: pointer; + font-size: 1.2rem; + color: #888; + z-index: 10; + padding: 0; + line-height: 1; +} +.clear-btn:hover { + color: #333; +} +.copy-btn { + position: absolute; + right: 10px; + top: 17%; + transform: translateY(-50%); + background: transparent; + border: none; + cursor: pointer; + font-size: 1.2rem; + color: #888; + z-index: 10; + padding: 0; + line-height: 1; +} +.copy-btn:hover { + color: #333; +} + +.marginBottomNone{ + margin-bottom: 0px !important; +} \ No newline at end of file diff --git a/HRM.UI/ClientApp/src/app/authentication/cipher-engine/cipher-engine.component.ts b/HRM.UI/ClientApp/src/app/authentication/cipher-engine/cipher-engine.component.ts new file mode 100644 index 0000000..61f9cd7 --- /dev/null +++ b/HRM.UI/ClientApp/src/app/authentication/cipher-engine/cipher-engine.component.ts @@ -0,0 +1,61 @@ +import { loadingPanelService } from './../../hrm-loding panel/loding.panel.service'; +import {Component, OnInit} from '@angular/core'; +import { AuthService } from 'src/app/_services/auth/auth.service'; +import { ApiService } from 'src/app/app.api.service'; +import { HRMNotificationService } from 'src/app/app.notification.service'; + +@Component({ + selector: 'app-cipher-engine', + templateUrl: './cipher-engine.component.html', + styleUrl: './cipher-engine.component.scss', + standalone: false, +}) +export class CipherEngineComponent implements OnInit{ + constructor(public notificationService: HRMNotificationService, + public authService: AuthService, public apiService: ApiService, + public loadingPanelService : loadingPanelService) { + this.apiService.selectedMenuName = 'Cipher Engine'; + } + + decryptedvalue : any = ""; + encryptedValue : any = ""; + + ngOnInit() { + this.decryptedvalue = ""; + this.encryptedValue = ""; + } + clearInput() { + this.decryptedvalue = ""; + } + handleEnterKey(event: KeyboardEvent): void { + event.preventDefault(); + if (this.encryptedValue?.trim()) { + + } + } + CipherMechanism(){ + if(!this.decryptedvalue){ + this.notificationService.showWarning("Please enter text to encrypt first."); + return; + } + const data = { + decryptedvalue : this.decryptedvalue + } + this.loadingPanelService.ShowLoadingPanel = true; + this.authService.CipherMechanism(data).subscribe( + (resp: any) => { + this.encryptedValue = resp as string; + }, + (err) => { + this.loadingPanelService.ShowLoadingPanel = false; + this.notificationService.showError(err.error); + }, + () => { + this.loadingPanelService.ShowLoadingPanel = false; + }); + } + copyDecryptValueToClipboard(){ + if (!this.encryptedValue) return; + navigator.clipboard.writeText(this.encryptedValue).catch(() => {}); + } +} diff --git a/HRM.UI/ClientApp/src/app/kendo-icons.module.ts b/HRM.UI/ClientApp/src/app/kendo-icons.module.ts index bbd7e64..1f570c5 100644 --- a/HRM.UI/ClientApp/src/app/kendo-icons.module.ts +++ b/HRM.UI/ClientApp/src/app/kendo-icons.module.ts @@ -44,7 +44,9 @@ import { imageIcon, shareIcon, zoomInIcon, - zoomOutIcon + zoomOutIcon, + copyIcon, + forwardIcon } from '@progress/kendo-svg-icons'; @NgModule({}) @@ -93,6 +95,8 @@ export class KendoIconsModule { image: imageIcon, share: shareIcon, zoomIn: zoomInIcon, - zoomOut: zoomOutIcon + zoomOut: zoomOutIcon, + copy : copyIcon, + forward : forwardIcon }; } diff --git a/HRM.UI/Controllers/Auth/AuthController.cs b/HRM.UI/Controllers/Auth/AuthController.cs index 757e8fe..342fefd 100644 --- a/HRM.UI/Controllers/Auth/AuthController.cs +++ b/HRM.UI/Controllers/Auth/AuthController.cs @@ -739,6 +739,26 @@ namespace HRM.UI.Controllers return Ok(new { userToken }); } + [HttpPost("CipherMechanism")] + public ActionResult CipherMechanism(dynamic data) + { + var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); + string decryptedvalue = (string)item["decryptedvalue"].ToObject(); + var encryptedValue = ""; + try + { + if (!string.IsNullOrEmpty(decryptedvalue)) + { + encryptedValue = Ease.NetCore.Utility.Global.CipherFunctions.Encrypt("CeLiMiTeD.AdMIn", decryptedvalue.Trim()); + } + } + catch (Exception e) + { + return StatusCode(StatusCodes.Status500InternalServerError, e.Message); + } + return Ok(encryptedValue); + } + // Clears the HttpOnly "JWToken" cookie the API authenticates from (see Startup), so the // session really ends on logout. Anonymous so an invalid/expired cookie can still be removed. [HttpPost("logOut")] diff --git a/HRM.UI/appsettings.json b/HRM.UI/appsettings.json index 620a8f4..607abe1 100644 --- a/HRM.UI/appsettings.json +++ b/HRM.UI/appsettings.json @@ -52,8 +52,8 @@ //"Default": "provider=sql;sqlSyntax=SQL;server=103.197.204.164,1718;Database=MasterProjectDB;User Id=DBuser;Password=ceLEa&e2025;TrustServerCertificate=True;", //"SqlCommandConnection": "Data Source=103.197.204.164,1718;Initial Catalog=autocrop;Persist Security Info=True; User ID=DBuser;Password=ceLEa&e2025;TrustServerCertificate=True;", // Development - "Default": "provider=sql;sqlSyntax=SQL;server=103.197.204.164,1718;Database=MasterProjectDBUATBRAC;User Id= DBuser;Password=ceLEa&e2025;TrustServerCertificate=True;", - "SqlCommandConnection": "Data Source=103.197.204.164,1718;Initial Catalog=MasterProjectDBUATBRAC;Persist Security Info=True; User ID=DBuser;Password=ceLEa&e2025;TrustServerCertificate=True;" // Development + "Default": "provider=sql;sqlSyntax=SQL;server=103.197.204.164,1718;Database=MasterProjectDBBRAC;User Id= DBuser;Password=ceLEa&e2025;TrustServerCertificate=True;", + "SqlCommandConnection": "Data Source=103.197.204.164,1718;Initial Catalog=MasterProjectDBBRAC;Persist Security Info=True; User ID=DBuser;Password=ceLEa&e2025;TrustServerCertificate=True;" // Development }, "Calendar": {