-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
520 changed files
with
19,937 additions
and
32,918 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
namespace Xxtea { | ||
using System; | ||
using System.Text; | ||
|
||
public sealed class XXTEA { | ||
private static readonly UTF8Encoding utf8 = new UTF8Encoding(); | ||
|
||
private const UInt32 delta = 0x9E3779B9; | ||
|
||
private static UInt32 MX(UInt32 sum, UInt32 y, UInt32 z, Int32 p, UInt32 e, UInt32[] k) { | ||
return (z >> 5 ^ y << 2) + (y >> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z); | ||
} | ||
|
||
private XXTEA() { | ||
} | ||
|
||
public static Byte[] Encrypt(Byte[] data, Byte[] key) { | ||
if (data.Length == 0) { | ||
return data; | ||
} | ||
return ToByteArray(Encrypt(ToUInt32Array(data, true), ToUInt32Array(FixKey(key), false)), false); | ||
} | ||
|
||
public static Byte[] Encrypt(String data, Byte[] key) { | ||
return Encrypt(utf8.GetBytes(data), key); | ||
} | ||
|
||
public static Byte[] Encrypt(Byte[] data, String key) { | ||
return Encrypt(data, utf8.GetBytes(key)); | ||
} | ||
|
||
public static Byte[] Encrypt(String data, String key) { | ||
return Encrypt(utf8.GetBytes(data), utf8.GetBytes(key)); | ||
} | ||
|
||
public static String EncryptToBase64String(Byte[] data, Byte[] key) { | ||
return Convert.ToBase64String(Encrypt(data, key)); | ||
} | ||
|
||
public static String EncryptToBase64String(String data, Byte[] key) { | ||
return Convert.ToBase64String(Encrypt(data, key)); | ||
} | ||
|
||
public static String EncryptToBase64String(Byte[] data, String key) { | ||
return Convert.ToBase64String(Encrypt(data, key)); | ||
} | ||
|
||
public static String EncryptToBase64String(String data, String key) { | ||
return Convert.ToBase64String(Encrypt(data, key)); | ||
} | ||
|
||
public static Byte[] Decrypt(Byte[] data, Byte[] key) { | ||
if (data.Length == 0) { | ||
return data; | ||
} | ||
return ToByteArray(Decrypt(ToUInt32Array(data, false), ToUInt32Array(FixKey(key), false)), true); | ||
} | ||
|
||
public static Byte[] Decrypt(Byte[] data, String key) { | ||
return Decrypt(data, utf8.GetBytes(key)); | ||
} | ||
|
||
public static Byte[] DecryptBase64String(String data, Byte[] key) { | ||
return Decrypt(Convert.FromBase64String(data), key); | ||
} | ||
|
||
public static Byte[] DecryptBase64String(String data, String key) { | ||
return Decrypt(Convert.FromBase64String(data), key); | ||
} | ||
|
||
public static String DecryptToString(Byte[] data, Byte[] key) { | ||
return utf8.GetString(Decrypt(data, key)); | ||
} | ||
|
||
public static String DecryptToString(Byte[] data, String key) { | ||
return utf8.GetString(Decrypt(data, key)); | ||
} | ||
|
||
public static String DecryptBase64StringToString(String data, Byte[] key) { | ||
return utf8.GetString(DecryptBase64String(data, key)); | ||
} | ||
|
||
public static String DecryptBase64StringToString(String data, String key) { | ||
return utf8.GetString(DecryptBase64String(data, key)); | ||
} | ||
|
||
private static UInt32[] Encrypt(UInt32[] v, UInt32[] k) { | ||
Int32 n = v.Length - 1; | ||
if (n < 1) { | ||
return v; | ||
} | ||
UInt32 z = v[n], y, sum = 0, e; | ||
Int32 p, q = 6 + 52 / (n + 1); | ||
unchecked { | ||
while (0 < q--) { | ||
sum += delta; | ||
e = sum >> 2 & 3; | ||
for (p = 0; p < n; p++) { | ||
y = v[p + 1]; | ||
z = v[p] += MX(sum, y, z, p, e, k); | ||
} | ||
y = v[0]; | ||
z = v[n] += MX(sum, y, z, p, e, k); | ||
} | ||
} | ||
return v; | ||
} | ||
|
||
private static UInt32[] Decrypt(UInt32[] v, UInt32[] k) { | ||
Int32 n = v.Length - 1; | ||
if (n < 1) { | ||
return v; | ||
} | ||
UInt32 z, y = v[0], sum, e; | ||
Int32 p, q = 6 + 52 / (n + 1); | ||
unchecked { | ||
sum = (UInt32)(q * delta); | ||
while (sum != 0) { | ||
e = sum >> 2 & 3; | ||
for (p = n; p > 0; p--) { | ||
z = v[p - 1]; | ||
y = v[p] -= MX(sum, y, z, p, e, k); | ||
} | ||
z = v[n]; | ||
y = v[0] -= MX(sum, y, z, p, e, k); | ||
sum -= delta; | ||
} | ||
} | ||
return v; | ||
} | ||
|
||
private static Byte[] FixKey(Byte[] key) { | ||
if (key.Length == 16) return key; | ||
Byte[] fixedkey = new Byte[16]; | ||
if (key.Length < 16) { | ||
key.CopyTo(fixedkey, 0); | ||
} | ||
else { | ||
Array.Copy(key, 0, fixedkey, 0, 16); | ||
} | ||
return fixedkey; | ||
} | ||
|
||
private static UInt32[] ToUInt32Array(Byte[] data, Boolean includeLength) { | ||
Int32 length = data.Length; | ||
Int32 n = (((length & 3) == 0) ? (length >> 2) : ((length >> 2) + 1)); | ||
UInt32[] result; | ||
if (includeLength) { | ||
result = new UInt32[n + 1]; | ||
result[n] = (UInt32)length; | ||
} | ||
else { | ||
result = new UInt32[n]; | ||
} | ||
for (Int32 i = 0; i < length; i++) { | ||
result[i >> 2] |= (UInt32)data[i] << ((i & 3) << 3); | ||
} | ||
return result; | ||
} | ||
|
||
private static Byte[] ToByteArray(UInt32[] data, Boolean includeLength) { | ||
Int32 n = data.Length << 2; | ||
if (includeLength) { | ||
Int32 m = (Int32)data[data.Length - 1]; | ||
n -= 4; | ||
if ((m < n - 3) || (m > n)) { | ||
return null; | ||
} | ||
n = m; | ||
} | ||
Byte[] result = new Byte[n]; | ||
for (Int32 i = 0; i < n; i++) { | ||
result[i] = (Byte)(data[i >> 2] >> ((i & 3) << 3)); | ||
} | ||
return result; | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
AutofaceXlua/unity/AppFrameCore/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// 有关程序集的一般信息由以下 | ||
// 控制。更改这些特性值可修改 | ||
// 与程序集关联的信息。 | ||
[assembly: AssemblyTitle("AppFrameCore")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("AppFrameCore")] | ||
[assembly: AssemblyCopyright("Copyright © 2017")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
//将 ComVisible 设置为 false 将使此程序集中的类型 | ||
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, | ||
//请将此类型的 ComVisible 特性设置为 true。 | ||
[assembly: ComVisible(false)] | ||
|
||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID | ||
[assembly: Guid("50802f8d-5d0f-49ca-a13c-1c25bfd1f8f6")] | ||
|
||
// 程序集的版本信息由下列四个值组成: | ||
// | ||
// 主版本 | ||
// 次版本 | ||
// 生成号 | ||
// 修订号 | ||
// | ||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, | ||
// 方法是按如下所示使用“*”: : | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
Binary file not shown.
Binary file not shown.
Binary file not shown.
107 changes: 0 additions & 107 deletions
107
...ect/Code/Core/Plugins/Autofac/Autofac.xml → .../unity/AppFrameCore/bin/Debug/Autofac.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions
4
...3RD/AutofaceTest/Examples/1.0_ToXlua.meta → ...nity/AutoFaceAndXlua/Assets/3RD/7zip.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...s/3RD/XLua/Examples/09_GenericMethod.meta → ...toFaceAndXlua/Assets/3RD/7zip/Common.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.