コード例 #1
0
ファイル: Crypt.cs プロジェクト: wy182000/mahjong
        public static byte[] desdecode(byte[] key, byte[] encrypted)
        {
            UnityEngine.Debug.Assert(key.Length == 8);
            try {
                IntPtr keyptr = Marshal.AllocHGlobal(key.Length);
                Marshal.Copy(key, 0, keyptr, key.Length);
                Crypt_CSharp.PACKAGE pgkey;
                pgkey.src = keyptr;
                pgkey.len = key.Length;

                IntPtr ptr = Marshal.AllocHGlobal(encrypted.Length);
                Marshal.Copy(encrypted, 0, ptr, encrypted.Length);
                Crypt_CSharp.PACKAGE pg;
                pg.src = ptr;
                pg.len = encrypted.Length;

                Crypt_CSharp.PACKAGE res = Crypt_CSharp.desdecode(pgkey, pg);
                byte[] buffer            = new byte[res.len];
                Marshal.Copy(res.src, buffer, 0, res.len);
                pfree(res);

                Marshal.FreeHGlobal(keyptr);
                Marshal.FreeHGlobal(ptr);
                return(buffer);
            } catch (Exception) {
                throw;
            }
        }
コード例 #2
0
ファイル: Crypt.cs プロジェクト: wy182000/mahjong
        public static byte[] hmac_hash(byte[] key, byte[] data)
        {
            try {
                UnityEngine.Debug.Assert(key.Length == 8);
                IntPtr keyptr = Marshal.AllocHGlobal(key.Length);
                Marshal.Copy(key, 0, keyptr, key.Length);
                Crypt_CSharp.PACKAGE keypg;
                keypg.src = keyptr;
                keypg.len = key.Length;

                IntPtr ptr = Marshal.AllocHGlobal(data.Length);
                Marshal.Copy(data, 0, ptr, data.Length);
                Crypt_CSharp.PACKAGE pg;
                pg.src = ptr;
                pg.len = data.Length;

                Crypt_CSharp.PACKAGE res = Crypt_CSharp.hmac_hash(keypg, pg);
                byte[] buffer            = new byte[res.len];
                Marshal.Copy(res.src, buffer, 0, res.len);
                pfree(res);

                Marshal.FreeHGlobal(keyptr);
                Marshal.FreeHGlobal(ptr);
                return(buffer);
            } catch (Exception) {
                throw;
            }
        }
コード例 #3
0
ファイル: Crypt.cs プロジェクト: wy182000/mahjong
        public static byte[] hmac64(byte[] key1, byte[] key2)
        {
            try {
                IntPtr keyptr1 = Marshal.AllocHGlobal(key1.Length);
                Marshal.Copy(key1, 0, keyptr1, key1.Length);
                Crypt_CSharp.PACKAGE pgkey1;
                pgkey1.src = keyptr1;
                pgkey1.len = key1.Length;

                IntPtr keyptr2 = Marshal.AllocHGlobal(key2.Length);
                Marshal.Copy(key2, 0, keyptr2, key2.Length);
                Crypt_CSharp.PACKAGE pgkey2;
                pgkey2.src = keyptr2;
                pgkey2.len = key2.Length;
                Crypt_CSharp.PACKAGE res = Crypt_CSharp.hmac64(pgkey1, pgkey2);
                byte[] buffer            = new byte[res.len];
                Marshal.Copy(res.src, buffer, 0, res.len);
                pfree(res);

                Marshal.FreeHGlobal(keyptr1);
                Marshal.FreeHGlobal(keyptr2);
                return(buffer);
            } catch (Exception) {
                throw;
            }
        }
コード例 #4
0
ファイル: Crypt.cs プロジェクト: wy182000/mahjong
        public static byte[] dhsecret(byte[] key, byte[] src)
        {
            try {
                IntPtr keyptr = Marshal.AllocHGlobal(key.Length);
                Marshal.Copy(key, 0, keyptr, key.Length);
                Crypt_CSharp.PACKAGE pgkey;
                pgkey.src = keyptr;
                pgkey.len = key.Length;

                IntPtr ptr = Marshal.AllocHGlobal(src.Length);
                Marshal.Copy(src, 0, ptr, src.Length);
                Crypt_CSharp.PACKAGE pg;
                pg.src = ptr;
                pg.len = src.Length;

                Crypt_CSharp.PACKAGE res = Crypt_CSharp.dhsecret(pgkey, pg);
                byte[] buffer            = new byte[res.len];
                Marshal.Copy(res.src, buffer, 0, res.len);
                pfree(res);

                Marshal.FreeHGlobal(keyptr);
                Marshal.FreeHGlobal(ptr);
                return(buffer);
            } catch (Exception) {
                throw;
            }
        }
コード例 #5
0
ファイル: Crypt.cs プロジェクト: wy182000/mahjong
 public static void pfree(Crypt_CSharp.PACKAGE data)
 {
     try {
         Crypt_CSharp.pfree(data);
     } catch (Exception) {
         throw;
     }
 }
コード例 #6
0
 public static byte[] randomkey()
 {
     try {
         IntPtr resptr = Crypt_CSharp.randomkey();
         byte[] buffer = Package.package_unpackarray(resptr);
         Package.package_free(resptr);
         return(buffer);
     } catch (Exception) {
         throw;
     }
 }
コード例 #7
0
ファイル: Crypt.cs プロジェクト: wy182000/mahjong
 public static byte[] randomkey()
 {
     try {
         Crypt_CSharp.PACKAGE res = Crypt_CSharp.randomkey();
         byte[] buffer            = new byte[res.len];
         Marshal.Copy(res.src, buffer, 0, res.len);
         pfree(res);
         return(buffer);
     } catch (Exception) {
         throw;
     }
 }
コード例 #8
0
 public static byte[] base64encode(byte[] src)
 {
     try {
         IntPtr srcptr = Package.package_packarray(src);
         IntPtr resptr = Crypt_CSharp.base64encode(srcptr);
         byte[] buffer = Package.package_unpackarray(resptr);
         Package.package_freezero(ref srcptr);
         Package.package_freezero(ref resptr);
         return(buffer);
     } catch (Exception) {
         throw;
     }
 }
コード例 #9
0
ファイル: Crypt.cs プロジェクト: Mephostopilis/origin
 public static byte[] hmac_sha1(byte[] src)
 {
     try {
         IntPtr srcptr = Package.package_packarray(src);
         IntPtr resptr = Crypt_CSharp.hmac_sha1(srcptr);
         byte[] buffer = Package.package_unpackarray(resptr);
         Package.package_free(srcptr);
         Package.package_free(resptr);
         return(buffer);
     } catch (Exception) {
         throw;
     }
 }
コード例 #10
0
 public static byte[] hexdecode(byte[] encrypted)
 {
     try {
         IntPtr encryptedptr = Package.package_packarray(encrypted);
         IntPtr resptr       = Crypt_CSharp.hexdecode(encryptedptr);
         byte[] buffer       = Package.package_unpackarray(resptr);
         Package.package_freezero(ref encryptedptr);
         Package.package_freezero(ref resptr);
         return(buffer);
     } catch (Exception) {
         throw;
     }
 }
コード例 #11
0
 public static byte[] hashkey(byte[] src)
 {
     UnityEngine.Debug.Assert(src.Length > 0);
     try {
         IntPtr srcptr = Package.package_packarray(src);
         IntPtr resptr = Crypt_CSharp.hashkey(srcptr);
         byte[] buffer = Package.package_unpackarray(resptr);
         Package.package_freezero(ref srcptr);
         Package.package_freezero(ref resptr);
         return(buffer);
     } catch (Exception) {
         throw;
     }
 }
コード例 #12
0
 public static byte[] hmac_hash(byte[] key, byte[] data)
 {
     try {
         IntPtr keyptr  = Package.package_packarray(key);
         IntPtr dataptr = Package.package_packarray(data);
         IntPtr resptr  = Crypt_CSharp.hmac_hash(keyptr, dataptr);
         byte[] buffer  = Package.package_unpackarray(resptr);
         Package.package_freezero(ref keyptr);
         Package.package_freezero(ref dataptr);
         Package.package_freezero(ref resptr);
         return(buffer);
     } catch (Exception) {
         throw;
     }
 }
コード例 #13
0
 public static byte[] hmac64(byte[] key1, byte[] key2)
 {
     try {
         IntPtr key1ptr = Package.package_packarray(key1);
         IntPtr key2ptr = Package.package_packarray(key2);
         IntPtr resptr  = Crypt_CSharp.hmac64(key1ptr, key2ptr);
         byte[] buffer  = Package.package_unpackarray(resptr);
         Package.package_freezero(ref key1ptr);
         Package.package_freezero(ref key2ptr);
         Package.package_freezero(ref resptr);
         return(buffer);
     } catch (Exception) {
         throw;
     }
 }
コード例 #14
0
 public static byte[] dhsecret(byte[] key, byte[] src)
 {
     try {
         IntPtr keyptr = Package.package_packarray(key);
         IntPtr srcptr = Package.package_packarray(src);
         IntPtr resptr = Crypt_CSharp.dhsecret(keyptr, srcptr);
         byte[] buffer = Package.package_unpackarray(resptr);
         Package.package_freezero(ref keyptr);
         Package.package_freezero(ref srcptr);
         Package.package_freezero(ref resptr);
         return(buffer);
     } catch (Exception) {
         throw;
     }
 }
コード例 #15
0
 public static byte[] desdecode(byte[] key, byte[] encrypted)
 {
     UnityEngine.Debug.Assert(key.Length == 8);
     try {
         IntPtr keyptr       = Package.package_packarray(key);
         IntPtr encryptedptr = Package.package_packarray(encrypted);
         IntPtr resptr       = Crypt_CSharp.desdecode(keyptr, encryptedptr);
         byte[] buffer       = Package.package_unpackarray(resptr);
         Package.package_freezero(ref keyptr);
         Package.package_freezero(ref encryptedptr);
         Package.package_freezero(ref resptr);
         return(buffer);
     } catch (Exception) {
         throw;
     }
 }
コード例 #16
0
ファイル: Crypt.cs プロジェクト: Mephostopilis/origin
 public static byte[] desencode(byte[] key, byte[] src)
 {
     UnityEngine.Debug.Assert(key.Length > 0);
     UnityEngine.Debug.Assert(src.Length > 0);
     try {
         IntPtr keyptr = Package.package_packarray(key);
         IntPtr srcptr = Package.package_packarray(src);
         IntPtr resptr = Crypt_CSharp.desencode(keyptr, srcptr);
         byte[] buffer = Package.package_unpackarray(resptr);
         Package.package_free(keyptr);
         Package.package_free(srcptr);
         Package.package_free(resptr);
         return(buffer);
     } catch (Exception) {
         throw;
     }
 }
コード例 #17
0
ファイル: Crypt.cs プロジェクト: wy182000/mahjong
        public static byte[] hexencode(byte[] src)
        {
            try {
                IntPtr ptr = Marshal.AllocHGlobal(src.Length);
                Marshal.Copy(src, 0, ptr, src.Length);
                Crypt_CSharp.PACKAGE pg;
                pg.src = ptr;
                pg.len = src.Length;

                Crypt_CSharp.PACKAGE res = Crypt_CSharp.hexencode(pg);
                byte[] buffer            = new byte[res.len];
                Marshal.Copy(res.src, buffer, 0, res.len);
                pfree(res);

                Marshal.FreeHGlobal(ptr);
                return(buffer);
            } catch (Exception ex) {
                throw;
            }
        }
コード例 #18
0
ファイル: Crypt.cs プロジェクト: wy182000/mahjong
        public static byte[] base64decode(byte[] encrypted)
        {
            try {
                IntPtr ptr = Marshal.AllocHGlobal(encrypted.Length);
                Marshal.Copy(encrypted, 0, ptr, encrypted.Length);
                Crypt_CSharp.PACKAGE pg;
                pg.src = ptr;
                pg.len = encrypted.Length;

                Crypt_CSharp.PACKAGE res = Crypt_CSharp.base64decode(pg);
                byte[] buffer            = new byte[res.len];
                Marshal.Copy(res.src, buffer, 0, res.len);
                pfree(res);

                Marshal.FreeHGlobal(ptr);
                return(buffer);
            } catch (Exception) {
                throw;
            }
        }