示例#1
0
        protected void testDes()
        {
            //string testStr = "asdfasdf5";
            //byte[] inBytes = System.Text.Encoding.UTF8.GetBytes(testStr);
            //byte[] key = { 0x65, 0xC1, 0x78, 0xB2, 0x84, 0xD1, 0x97, 0xCC };
            byte[] key = { 26, 32, 127, 193, 251, 239, 174, 97 };
            //byte[] inBytes = { 0x3f, 0x79, 0xd5, 0xe2, 0x4a, 0x8c, 0xb6, 0xc1, 0x3f, 0x79, 0xd5, 0xe2, 0x4a, 0x8c, 0xb6, 0xc1 };
            byte[] inBytes  = { 0x0c, 0x00, 0x00, 0x00, 0x03, 0x35, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 };
            byte[] outBytes = new byte[16];
            uint   inSize   = (uint)inBytes.Length;

            DES_key_schedule des5Key = new DES_key_schedule();     // RC5 key

            Dec.DES_set_key_unchecked(key, des5Key);

            CryptContext cryptContext = new CryptContext();

            cryptContext.m_cryptAlgorithm = CryptAlgorithm.DES;
            cryptContext.setCryptKey(key);

            //Crypt.encryptData(inBytes, 0, 16, ref outBytes, des5Key, CryptAlgorithm.DES);
            //Crypt.decryptData(outBytes, 0, 16, ref inBytes, des5Key, CryptAlgorithm.DES);
            //testStr = System.Text.Encoding.UTF8.GetString(inBytes);
            Crypt.decryptData(inBytes, 0, 16, ref outBytes, cryptContext);
        }