mirror of
https://github.com/LBPUnion/UnionPatcher.git
synced 2025-04-20 11:36:14 +00:00
Squashed commit of the following: commit db54f752b1a7d876c8e8ac23f64fac0e133c6c42 Author: jvyden <jvyden@jvyden.xyz> Date: Tue Jun 14 21:50:24 2022 -0400 Fix warnings in Program.cs, remove version commit abab75e00a9fa5c762669365a130025b7fa28522 Author: jvyden <jvyden@jvyden.xyz> Date: Tue Jun 14 21:45:08 2022 -0400 Enforce file-scoped namespaces commit d004b8dd77546b0dedc572bc3e7849677a707697 Author: jvyden <jvyden@jvyden.xyz> Date: Tue Jun 14 21:43:53 2022 -0400 Cleanup remote patching commit d611df7e2e5ad86466acb3fe95b835e5df3efa38 Author: jvyden <jvyden@jvyden.xyz> Date: Tue Jun 14 21:25:57 2022 -0400 Theoretically working state commit 18b362e268d800bac3c6fa5c3ae0c0b896627648 Author: jvyden <jvyden@jvyden.xyz> Date: Tue Jun 14 21:10:58 2022 -0400 Import code from UnionRemotePatcher Co-authored-by: Logan Lowe <loganr.lowe@gmail.com>
27 lines
No EOL
652 B
C#
27 lines
No EOL
652 B
C#
using System;
|
|
|
|
namespace LBPUnion.UnionPatcher;
|
|
|
|
public static class IDPSHelper
|
|
{
|
|
public static byte[] StringToByteArray(string hex)
|
|
{
|
|
if (hex.Length % 2 == 1)
|
|
throw new Exception("The binary key cannot have an odd number of digits");
|
|
|
|
byte[] arr = new byte[hex.Length >> 1];
|
|
|
|
for (int i = 0; i < hex.Length >> 1; ++i)
|
|
{
|
|
arr[i] = (byte)((GetHexVal(hex[i << 1]) << 4) + (GetHexVal(hex[(i << 1) + 1])));
|
|
}
|
|
|
|
return arr;
|
|
}
|
|
|
|
public static int GetHexVal(char hex)
|
|
{
|
|
int val = (int)hex;
|
|
return val - (val < 58 ? 48 : (val < 97 ? 55 : 87));
|
|
}
|
|
} |