↓ मुख्य सामग्री पर जाएँ
  1. आर्टिकल्स/

विंडोज 8 में एईएस डिक्रिप्शन

Rubén Infante Docio
लेखक
Rubén Infante Docio
सॉफ़्टवेयर इंजीनियर

आज हम एन्क्रिप्शन की खूबसूरत दुनिया के बारे में बात करने जा रहे हैं, न कि](http://www.antonio-ramos.es/2008/06/cifrar-versus-encriptar.html) एन्क्रिप्टेड [(एक तहखाने में डाल दिया)।

सुरक्षा महत्वपूर्ण है, और इसीलिए हम यह देखने जा रहे हैं कि सर्वर पर एन्क्रिप्ट कैसे करें और मेट्रो अनुप्रयोगों में विंडोज 8 क्लाइंट को डिक्रिप्ट करें।

इस उदाहरण के लिए हम 256 बाइट एन्क्रिप्शन, (सैन्य एन्क्रिप्शन) के साथ एईएस का उपयोग करेंगे

सेवारत पार्टी
#

public string Get()
        {
            //
            String original = "1234567812345678";
            String key = "CLAVEDESEGURIDAD";
            byte[] KeyArr = System.Text.Encoding.ASCII.GetBytes(key);
            String iv = "VECTORINICIALIZACION";
            byte[] IvArr = System.Text.Encoding.ASCII.GetBytes(iv);
            using (AesManaged myAes = new AesManaged())
            {
                return EncryptStringToBytes_Aes(original, KeyArr, IvArr);
            }

        }
        static string EncryptStringToBytes_Aes(string plainText, byte[] Key, byte[] IV)
        {
            byte[] encrypted;
            using (AesManaged aesAlg = new AesManaged())
            {
                ICryptoTransform encryptor = aesAlg.CreateEncryptor(Key, IV);

                using (MemoryStream msEncrypt = new MemoryStream())
                {
                    using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
                    {
                        using (StreamWriter swEncrypt = new StreamWriter(csEncrypt))
                        {
                            swEncrypt.Write(plainText);
                            swEncrypt.Flush();
                            encrypted = msEncrypt.ToArray();
                            return Convert.ToBase64String(encrypted);
                        }
                    }
                }
            }

        }

ग्राहक भाग

 function RunSample(cadenacifradaenbase64) {

	var Algorithm = Windows.Security.Cryptography.Core.SymmetricKeyAlgorithmProvider.openAlgorithm("AES_CBC");
        	var keymaterial2 = Windows.Security.Cryptography.CryptographicBuffer.convertStringToBinary("CLAVEDESEGURIDAD", Windows.Security.Cryptography.BinaryStringEncoding.utf8);
        	var key2;
        	try {
        	    key2 = Algorithm.createSymmetricKey(keymaterial2);

        	}
       	 catch (ex) {
        	    Scenario5Output.textContent += ex.message;
        	    Scenario5Output.textContent += "An invalid key size was selected for the given algorithm.n";
        	    return;
       	 }
	var bufferCifrado = Windows.Security.Cryptography.CryptographicBuffer.decodeFromBase64String(cadenacifradaenbase64);
	var iv = Windows.Security.Cryptography.CryptographicBuffer.convertStringToBinary("VECTORINICIALIZACION", Windows.Security.Cryptography.BinaryStringEncoding.utf8);
	var decrypted = Windows.Security.Cryptography.Core.CryptographicEngine.decrypt(key2, bufferCifrado , iv);
        var solucion = Windows.Security.Cryptography.CryptographicBuffer.convertBinaryToString(Windows.Security.Cryptography.BinaryStringEncoding.utf8, decrypted);
}

अगर मैं देखता हूं कि आपको इस प्रकार का लेख पसंद है, तो अगले दिन हम रिवर्स प्रक्रिया को अंजाम देंगे

संबंधित