コード例 #1
0
ファイル: Encryptor.cs プロジェクト: aschoerk/cryptDotNetJava
        public byte[] DecryptTestWise(byte[] toDecrypt, string xmlPrivate)
        {
            //Encode with public key
            RSACryptoServiceProvider rsaPrivate = new RSACryptoServiceProvider();

            rsaPrivate.FromXmlString(xmlPrivate);

            int len = toDecrypt[0] + toDecrypt[1] * 256;

            byte[] encryptedSymmetricKey = new byte[len];
            for (int i = 0; i < len; i++)
            {
                encryptedSymmetricKey[i] = toDecrypt[i + 2];
            }

            byte[] encryptedData = new byte[toDecrypt.Length - 2 - len];
            for (int i = 0; i < encryptedData.Length; i++)
            {
                encryptedData[i] = toDecrypt[i + 2 + len];
            }

            byte[] decryptedKey = rsaPrivate.Decrypt(encryptedSymmetricKey, false);


            SymmetricKey s = new SymmetricKey();

            s.fromByteArray(decryptedKey);

            return(DecryptTestwise(encryptedData, s));
        }