add game manifest hash algorithm

This commit is contained in:
CroakFang
2022-12-13 23:09:47 +08:00
parent f942acb6ef
commit fd39c75a64
+7 -5
View File
@@ -3,11 +3,8 @@ using System;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
using UnityEngine; using UnityEngine;
public class ManifestEntry
namespace Assets.Editor.RootMotion
{ {
public class ManifestEntry
{
public static byte[] CalHame(ulong checksum, ulong size, byte[] name) public static byte[] CalHame(ulong checksum, ulong size, byte[] name)
{ {
if (name == null) return null; if (name == null) return null;
@@ -15,7 +12,7 @@ namespace Assets.Editor.RootMotion
byte[] allbyte = new byte[name.Length + 16]; byte[] allbyte = new byte[name.Length + 16];
byte[] checksumByte = BitConverter.GetBytes(checksum); byte[] checksumByte = BitConverter.GetBytes(checksum);
byte[] sizeByte = BitConverter.GetBytes(size); byte[] sizeByte = BitConverter.GetBytes(size);
for(int i=0; i < 16; i++) for (int i = 0; i < 16; i++)
{ {
allbyte[i] = (i < 8 ? checksumByte[7 - i] : sizeByte[15 - i]); allbyte[i] = (i < 8 ? checksumByte[7 - i] : sizeByte[15 - i]);
} }
@@ -29,5 +26,10 @@ namespace Assets.Editor.RootMotion
Base32 base32 = new Base32(); Base32 base32 = new Base32();
return base32.Encode(bytes); return base32.Encode(bytes);
} }
public static string CalHameString(ulong checksum, ulong size, string name)
{
return CalHameString(checksum, size, Encoding.UTF8.GetBytes(name));
} }
} }