コード例 #1
0
ファイル: ConvertEx.cs プロジェクト: chosong/DotnetServer
        public static string ToBase62(uint[] key)
        {
            if (key.Length != 4)
            {
                throw new Exception("Wrong Key Length");
            }

            byte[] buffer = new byte[16];
            Buffer.BlockCopy(BitConverter.GetBytes(key[0]), 0, buffer, 0, 4);
            Buffer.BlockCopy(BitConverter.GetBytes(key[1]), 0, buffer, 4, 4);
            Buffer.BlockCopy(BitConverter.GetBytes(key[2]), 0, buffer, 8, 4);
            Buffer.BlockCopy(BitConverter.GetBytes(key[3]), 0, buffer, 12, 4);

            return(Base62.ToBase62(buffer));
        }
コード例 #2
0
ファイル: ConvertEx.cs プロジェクト: chosong/DotnetServer
        public static uint[] ToKey(string base62)
        {
            byte[] keyBytes = Base62.FromBase62(base62);
            if (keyBytes.Length < 16)
            {
                throw new Exception("Wrong Key Length");
            }

            uint[] key = new uint[4];
            key[0] = BitConverter.ToUInt32(keyBytes, 0);
            key[1] = BitConverter.ToUInt32(keyBytes, 4);
            key[2] = BitConverter.ToUInt32(keyBytes, 8);
            key[3] = BitConverter.ToUInt32(keyBytes, 12);

            return(key);
        }