Skip to content

Commit

Permalink
Added the ability to reverse the hex kuid uid-cid
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverGreen93 committed Aug 27, 2017
1 parent ec39224 commit b53bc54
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 11 deletions.
5 changes: 4 additions & 1 deletion Kuid2Hash.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
<PropertyGroup>
<ApplicationIcon>Chromatix-Keyboard-Keys-Hash.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>My Project\app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
Expand All @@ -60,7 +63,6 @@
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup>
<Import Include="Microsoft.VisualBasic" />
Expand Down Expand Up @@ -111,6 +113,7 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="My Project\app.manifest" />
<None Include="My Project\Application.myapp">
<Generator>MyApplicationCodeGenerator</Generator>
<LastGenOutput>Application.Designer.vb</LastGenOutput>
Expand Down
8 changes: 4 additions & 4 deletions My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Imports System.Runtime.InteropServices
' Review the values of the assembly attributes

<Assembly: AssemblyTitle("Kuid2Hash")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyDescription("Utility for converting numeric kuids to hexadecimal values.")>
<Assembly: AssemblyCompany("vvmm")>
<Assembly: AssemblyProduct("Kuid2Hash")>
<Assembly: AssemblyCopyright("Copyright © vvmm 2016")>
<Assembly: AssemblyCopyright("Copyright © vvmm 2017")>
<Assembly: AssemblyTrademark("")>

<Assembly: ComVisible(False)>
Expand All @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>
<Assembly: AssemblyVersion("1.1.0.0")>
<Assembly: AssemblyFileVersion("1.1.0.0")>
76 changes: 76 additions & 0 deletions My Project/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on and is
is designed to work with. Uncomment the appropriate elements and Windows will
automatically selected the most compatible environment. -->

<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->

<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->

<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->

<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->

<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->

</application>
</compatibility>

<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>
-->

<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->

</assembly>
25 changes: 21 additions & 4 deletions frmKuid.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 40 additions & 2 deletions frmKuid.vb
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,39 @@ Public Class frmKuid
Return data
End Function


''' <summary>
''' Reverses the UID with the CID (for map files)
''' </summary>
''' <param name="kuid">The kuid as 8 bytes</param>
''' <returns>The reversed kuid as 8 bytes</returns>
''' <remarks></remarks>
Function revKuid(ByVal kuid As Byte()) As Byte()

Dim rbytes(7) As Byte 'returned bytes

Try
'reverse bytes (a-b-c-d-e-f-g-h -> e-f-g-h-a-b-c-d)
For i As Integer = 0 To 3
rbytes(i) = kuid(i + 4)
rbytes(i + 4) = kuid(i)
Next
Catch ex As Exception
MessageBox.Show(ex.ToString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try

Return rbytes

End Function

Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles txtKuid.TextChanged
If txtKuid.Focused = True Then
txtHash.Text = "hash-" & BitConverter.ToString(computeHash(KuidToHex(txtKuid.Text)))
txtHex.Text = BitConverter.ToString(KuidToHex(txtKuid.Text)).Replace("-"c, " "c)
If CheckBox1.Checked = True Then
txtHex.Text = BitConverter.ToString(revKuid(KuidToHex(txtKuid.Text))).Replace("-"c, " "c)
Else
txtHex.Text = BitConverter.ToString(KuidToHex(txtKuid.Text)).Replace("-"c, " "c)
End If
End If
End Sub

Expand All @@ -154,8 +183,17 @@ Public Class frmKuid

Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles txtHex.TextChanged
If txtHex.Focused = True Then
txtKuid.Text = HexToKuid(ConvertHex(txtHex.Text))
If CheckBox1.Checked = True Then
txtKuid.Text = HexToKuid(revKuid(ConvertHex(txtHex.Text)))
Else
txtKuid.Text = HexToKuid(ConvertHex(txtHex.Text))
End If
txtHash.Text = "hash-" & BitConverter.ToString(computeHash(KuidToHex(txtKuid.Text)))
End If
End Sub

Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
txtHex.Text = BitConverter.ToString(revKuid(ConvertHex(txtHex.Text))).Replace("-"c, " "c)
End Sub

End Class

0 comments on commit b53bc54

Please sign in to comment.