传奇3外挂加密解密过程(C#)版

传奇3外挂加密解密过程(C#)版

加密算法1:public string Base64Encode(string source){byte[] a1,a2,a3;BitArray b1,b2,b3;a1 = Encoding.Default.GetBytes(source);if (a1.Length % 3 == 0) a2 = new byte[a1.Length*4/3];else a2 = new byte[a1.Length*4/3+1];a3 = new byte[1];b1 = new BitArray(a1);b2 = new BitArray(6);b3 = new BitArray(b1.Length);for (int i = 0, k = b1.Length / 8; i < k; i++) {for(int j=7;j>=0;j--)b3[i*8+j]=b1[i*8+7-j];}for (int i = 0,k=b1.Length/6; i < k; i++){for (int j = 0; j < 6; j++){b2[5-j] = b3[i * 6 + j];}b2.CopyTo(a3,0);a2[i] = a3[0];}if (a1.Length % 3 == 1) a2[a2.Length - 1] = (byte)((byte)(a1[a1.Length - 1] << 6) >> 2);else if (a1.Length % 3 == 2) a2[a2.Length - 1] = (byte)((byte)(a1[a1.Length - 1] << 4 )>> 2);for (int i=0; i < a2.Length; i++) a2[i] = (byte)(a2[i] + 0x3c);return Encoding.Default.GetString(a2);}加密算法2:public string Base64Encode(string source){byte[] a1, a2;a1 = Encoding.Default.GetBytes(source);if (a1.Length % 3 == 0) a2 = new byte[a1.Length * 4 / 3];else a2 = new byte[a1.Length * 4 / 3 + 1];for (int i = 0, k = a1.Length / 3; i < k; i++) {a2[i*4] = (byte)(a1[i*3] >> 2);a2[i*4 + 1] = (byte)((byte)((byte)(a1[i*3] << 6) >> 2) + (byte)(a1[i*3 + 1] >> 4));a2[i*4 + 2] = (byte)((byte)((byte)(a1[i*3 + 1] << 4) >> 2) + (byte)(a1[i*3 + 2] >> 6));a2[i*4 + 3] = (byte)((byte)(a1[i*3 + 2] << 2) >> 2);}if (a1.Length % 3 == 1){a2[a2.Length - 2] = (byte)(a1[a1.Length - 1] >> 2);a2[a2.Length - 1] = (byte)((byte)(a1[a1.Length - 1] << 6) >> 2);}elseif (a1.Length % 3 == 2){a2[a2.Length - 3] = (byte)(a1[a1.Length - 2] >> 2);a2[a2.Length - 2] = (byte)((byte)((byte)(a1[a1.Length - 2] << 6) >> 2) + (byte)(a1[a1.Length - 1] >> 4));a2[a2.Length - 1] = (byte)((byte)(a1[a1.Length - 1] << 4) >> 2);}for (int i = 0; i < a2.Length; i++) a2[i] = (byte)(a2[i] + 0x3c);return Encoding.Default.GetString(a2);}解密算法:public string Base64Decode(string source) {byte[] a1, a2;a1 = Encoding.Default.GetBytes(source);a2 = new byte[a1.Length * 3 / 4];for (int i = 0; i < a1.Length; i++) a1[i] = (byte)(a1[i] - 0x3c);for (int i = 0, k = a1.Length / 4; i < k; i++){a2[i * 3] = (byte)((byte)(a1[i * 4] << 2) + (byte)(a1[i * 4 + 1] >> 4));a2[i * 3 + 1] = (byte)((byte)(a1[i * 4 + 1] << 4) + (byte)(a1[i * 4 + 2] >> 2));a2[i * 3 + 2] = (byte)((byte)(a1[i * 4 + 2] << 6) + a1[i * 4 + 3]);}if (a2.Length % 3 == 2){a2[a2.Length - 2] = (byte)((byte)(a1[a1.Length - 3] << 2) + (byte)(a1[a1.Length - 2] >> 4));a2[a2.Length - 1] = (byte)((byte)(a1[a1.Length - 2] << 4) + (byte)(a1[a1.Length - 1] >> 2));}elseif (a2.Length % 3 == 1) a2[a2.Length - 1] = (byte)((byte)(a1[a1.Length - 2] << 2) + (byte)(a1[a1.Length - 1] >> 4));return Encoding.Default.GetString(a2);}

转载于:.html

发布者:admin,转转请注明出处:http://www.yc00.com/news/1695257366a751958.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信