// 書き出す
        public void WriteToBuf(Buf b, ValueType type)
        {
            switch (type)
            {
            case ValueType.Int:
                b.WriteInt(IntValue);
                break;

            case ValueType.Int64:
                b.WriteInt64(Int64Value);
                break;

            case ValueType.Data:
                b.WriteInt((uint)Data.Length);
                b.Write(Data);
                break;

            case ValueType.Str:
                b.WriteStr(StrValue.Trim());
                break;

            case ValueType.UniStr:
                byte[] data = Str.Utf8Encoding.GetBytes(StrValue.Trim());
                b.WriteInt((uint)data.Length + 1);
                b.Write(data);
                b.WriteByte(0);
                break;
            }
        }
        // PKCS パディング
        public static byte[] PkcsPadding(byte[] srcData, int destSize)
        {
            int srcSize = srcData.Length;

            if ((srcSize + 11) > destSize)
            {
                throw new OverflowException();
            }

            int randSize = destSize - srcSize - 3;

            byte[] rand = Secure.Rand((uint)randSize);

            Buf b = new Buf();

            b.WriteByte(0x00);
            b.WriteByte(0x02);
            b.Write(rand);
            b.WriteByte(0x00);
            b.Write(srcData);

            return(b.ByteData);
        }