diff --git a/bytefy.webapp/src/app/app.routes.ts b/bytefy.webapp/src/app/app.routes.ts index 8a4a247..9643283 100644 --- a/bytefy.webapp/src/app/app.routes.ts +++ b/bytefy.webapp/src/app/app.routes.ts @@ -9,6 +9,7 @@ import { ImageConverterComponent } from '../tools/server-side/image-converter/im import { WordCounterComponent } from '../tools/client-side/word-counter/word-counter.component'; import { ColorPickerComponent } from '../tools/client-side/color-picker/color-picker.component'; import { QrCodeGeneratorComponent } from '../tools/client-side/qr-code-generator/qr-code-generator.component'; +import { OracleGuidConverterComponent } from '../tools/client-side/oracle-guid-converter/oracle-guid-converter.component'; export const routes: Routes = [ { @@ -60,6 +61,11 @@ export const routes: Routes = [ path: 'color-picker', pathMatch: 'full', component: ColorPickerComponent + }, + { + path: 'oracle-guid-converter', + pathMatch: 'full', + component: OracleGuidConverterComponent } ]; diff --git a/bytefy.webapp/src/app/header/header.component.ts b/bytefy.webapp/src/app/header/header.component.ts index 3b7bca4..f52f090 100644 --- a/bytefy.webapp/src/app/header/header.component.ts +++ b/bytefy.webapp/src/app/header/header.component.ts @@ -90,6 +90,11 @@ export class HeaderComponent implements OnInit { label: 'Ascii to text', routerLink: 'ascii-to-text', routerLinkActiveOptions: { exact: true } + }, + { + label: 'Oracle GUID Converter', + routerLink: 'oracle-guid-converter', + routerLinkActiveOptions: { exact: true } } ] } diff --git a/bytefy.webapp/src/tools/client-side/oracle-guid-converter/oracle-guid-converter.component.html b/bytefy.webapp/src/tools/client-side/oracle-guid-converter/oracle-guid-converter.component.html new file mode 100644 index 0000000..7227230 --- /dev/null +++ b/bytefy.webapp/src/tools/client-side/oracle-guid-converter/oracle-guid-converter.component.html @@ -0,0 +1,27 @@ +
+

GUID to Oracle RAW(16) Converter

+ +
+

Convert GUID to RAW(16)

+ + + + + +

RAW(16) Output:

+

{{ output }}

+
+
+ +
+

Convert RAW(16) to GUID

+ + + + + +

GUID Output:

+

{{ converted }}

+
+
+
\ No newline at end of file diff --git a/bytefy.webapp/src/tools/client-side/oracle-guid-converter/oracle-guid-converter.component.scss b/bytefy.webapp/src/tools/client-side/oracle-guid-converter/oracle-guid-converter.component.scss new file mode 100644 index 0000000..dfb531b --- /dev/null +++ b/bytefy.webapp/src/tools/client-side/oracle-guid-converter/oracle-guid-converter.component.scss @@ -0,0 +1,40 @@ +.container { + display: flex; + flex-direction: column; + align-items: center; + justify-content: space-between; + + h2, h3, label { + color: #a5a5a5; + } + + .conversion-section { + display: flex; + flex-direction: column; + justify-content: space-between; + width: 100%; + } +} + +:host ::ng-deep p { // Idk about this -.- + color: #a5a5a5; +} + +input { + width: 100%; + padding: 10px; + font-size: 16px; + margin-bottom: 10px; + border: 1px solid #ccc; + border-radius: 4px; + } + + button { + padding: 10px 20px; + font-size: 16px; + background-color: #4CAF50; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } diff --git a/bytefy.webapp/src/tools/client-side/oracle-guid-converter/oracle-guid-converter.component.ts b/bytefy.webapp/src/tools/client-side/oracle-guid-converter/oracle-guid-converter.component.ts new file mode 100644 index 0000000..dc8f2e5 --- /dev/null +++ b/bytefy.webapp/src/tools/client-side/oracle-guid-converter/oracle-guid-converter.component.ts @@ -0,0 +1,84 @@ +import { CommonModule } from '@angular/common'; +import { Component } from '@angular/core'; +import { FormsModule } from '@angular/forms'; + +@Component({ + selector: 'app-oracle-guid-converter', + standalone: true, + imports: [ + FormsModule, + CommonModule + ], + templateUrl: './oracle-guid-converter.component.html', + styleUrl: './oracle-guid-converter.component.scss' +}) +export class OracleGuidConverterComponent { + guidInput: string = ''; + rawOutput: string = ''; + convertedGuid: string = ''; + + private isValidGuid(guid: string): boolean { + const guidPattern = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/; + return guidPattern.test(guid); + } + + private isValidRaw(raw: string): boolean { + const rawPattern = /^[0-9a-fA-F]{32}$/; + return rawPattern.test(raw); + } + + private guidToRaw(guid: string): string { + const hexParts = guid.replace(/-/g, ''); + const guidBytes = Array.from({ length: 16 }, (_, i) => + parseInt(hexParts.substr(i * 2, 2), 16) + ); + + const reorderedBytes = [ + guidBytes[3], guidBytes[2], guidBytes[1], guidBytes[0], + guidBytes[5], guidBytes[4], + guidBytes[7], guidBytes[6], + ...guidBytes.slice(8, 16) + ]; + + return reorderedBytes.map(b => b.toString(16).padStart(2, '0')).join('').toUpperCase(); + } + + private rawToGuid(raw: string): string { + const rawBytes = Array.from({ length: 16 }, (_, i) => + parseInt(raw.substring(i * 2, i * 2 + 2), 16) + ); + + const reorderedBytes = [ + rawBytes[3], rawBytes[2], rawBytes[1], rawBytes[0], + rawBytes[5], rawBytes[4], + rawBytes[7], rawBytes[6], + ...rawBytes.slice(8, 16) + ]; + + const hexArray = reorderedBytes.map(b => b.toString(16).padStart(2, '0')); + + return [ + hexArray.slice(0, 4).join(''), + hexArray.slice(4, 6).join(''), + hexArray.slice(6, 8).join(''), + hexArray.slice(8, 10).join(''), + hexArray.slice(10, 16).join('') + ].join('-'); + } + + onConvertToRaw(): void { + if (this.isValidGuid(this.guidInput)) { + this.rawOutput = this.guidToRaw(this.guidInput); + } else { + this.rawOutput = 'Invalid GUID format'; + } + } + + onConvertToGuid(): void { + if (this.isValidRaw(this.rawOutput)) { + this.convertedGuid = this.rawToGuid(this.rawOutput); + } else { + this.convertedGuid = 'Invalid RAW(16) format'; + } + } +}