protected void testRc5() { string testStr = "asdfasdf5"; //byte[] inBytes = System.Text.Encoding.UTF8.GetBytes(testStr); byte[] inBytes = { 0x3f, 0x79, 0xd5, 0xe2, 0x4a, 0x8c, 0xb6, 0xc1, 0x3f, 0x79, 0xd5, 0xe2, 0x4a, 0x8c, 0xb6, 0xc1 }; byte[] outBytes = new byte[8]; uint inSize = (uint)inBytes.Length; RC5_32_KEY rc5Key = new RC5_32_KEY(); // RC5 key RC5.RC5_32_set_key(rc5Key, 16, Crypt.RC5_KEY, RC5.RC5_12_ROUNDS); // 生成秘钥 CryptContext cryptContext = new CryptContext(); Crypt.encryptData(inBytes, 0, 16, ref outBytes, cryptContext); Crypt.decryptData(outBytes, 0, 16, ref inBytes, cryptContext); testStr = System.Text.Encoding.Default.GetString(inBytes); }
public CryptContext() { m_cryptKeyArr[(int)CryptAlgorithm.RC5] = new RC5_32_KEY(); m_cryptKeyArr[(int)CryptAlgorithm.DES] = new DES_key_schedule(); RC5.RC5_32_set_key(m_cryptKeyArr[(int)CryptAlgorithm.RC5] as RC5_32_KEY, 16, Crypt.RC5_KEY, RC5.RC5_12_ROUNDS); // 生成秘钥 }