تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
حول التشفير وفك التشفير
#2
جرب هذا الكود :

PHP كود :
       #region EncryptDecryptWord
 
       public string Encrypt(string textstring key)
 
       {
 
           if (Operators.CompareString(text""TextComparefalse) == 0)
 
           {
 
               return text;
 
           }
 
           try
            
{
 
               System.Security.Cryptography.TripleDESCryptoServiceProvider crp = new System.Security.Cryptography.TripleDESCryptoServiceProvider();
 
               UnicodeEncoding uEncode = new UnicodeEncoding();
 
               byte[] bytPlainText uEncode.GetBytes(text);
 
               System.IO.MemoryStream stmCipherText = new System.IO.MemoryStream();
 
               byte[] slt = new byte[] { 0123456789101112 };
 
               System.Security.Cryptography.Rfc2898DeriveBytes pdb = new System.Security.Cryptography.Rfc2898DeriveBytes(keyslt);
 
               byte[] bytDerivedKey pdb.GetBytes(24);
 
               crp.Key bytDerivedKey;
 
               crp.IV pdb.GetBytes(8);
 
               System.Security.Cryptography.CryptoStream csEncrypted = new System.Security.Cryptography.CryptoStream(stmCipherTextcrp.CreateEncryptor(), System.Security.Cryptography.CryptoStreamMode.Write);
 
               csEncrypted.Write(bytPlainText0bytPlainText.Length);
 
               csEncrypted.FlushFinalBlock();
 
               return Convert.ToBase64String(stmCipherText.ToArray());
 
           }
 
           catch (Exception ex)
 
           {
 
               Microsoft.VisualBasic.Interaction.MsgBox(ex.MessageMicrosoft.VisualBasic.MsgBoxStyle.Critical"Error");
 
               return null;
 
           }
 
       }
 
       public string Decrypt(string textstring key)
 
       {
 
           if (Operators.CompareString(text""TextComparefalse) == 0)
 
           {
 
               return text;
 
           }

 
           try
            
{
 
               System.Security.Cryptography.TripleDESCryptoServiceProvider crp = new System.Security.Cryptography.TripleDESCryptoServiceProvider();
 
               UnicodeEncoding uEncode = new UnicodeEncoding();
 
               byte[] bytCipherText Convert.FromBase64String(text);
 
               System.IO.MemoryStream stmPlainText = new System.IO.MemoryStream();
 
               System.IO.MemoryStream stmCipherText = new System.IO.MemoryStream(bytCipherText);
 
               byte[] slt = new byte[] { 0123456789101112 };
 
               System.Security.Cryptography.Rfc2898DeriveBytes pdb = new System.Security.Cryptography.Rfc2898DeriveBytes(keyslt);
 
               byte[] bytDerivedKey pdb.GetBytes(24);
 
               crp.Key bytDerivedKey;
 
               crp.IV pdb.GetBytes(8);
 
               System.Security.Cryptography.CryptoStream csDecrypted = new System.Security.Cryptography.CryptoStream(stmCipherTextcrp.CreateDecryptor(), System.Security.Cryptography.CryptoStreamMode.Read);
 
               System.IO.StreamWriter sw = new System.IO.StreamWriter(stmPlainText);
 
               System.IO.StreamReader sr = new System.IO.StreamReader(csDecrypted);
 
               sw.Write(sr.ReadToEnd());
 
               sw.Flush();
 
               csDecrypted.Clear();
 
               crp.Clear();
 
               return uEncode.GetString(stmPlainText.ToArray());
 
           }
 
           catch (Exception ex)
 
           {
 
               Microsoft.VisualBasic.Interaction.MsgBox(ex.MessageMicrosoft.VisualBasic.MsgBoxStyle.Critical"Error");
 
               return null;
 
           }
 
       }
 
       #endregion 
الرد }}}
تم الشكر بواسطة: ابراهيم ايبو


الردود في هذا الموضوع
حول التشفير وفك التشفير - بواسطة ro0omio0o1 - 31-12-21, 11:34 PM
RE: حول التشفير وفك التشفير - بواسطة asemshahen5 - 04-04-22, 09:43 PM

المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
Lightbulb [مشروع] سوال على التشفير sirwan 0 1,310 05-01-20, 08:37 PM
آخر رد: sirwan
  فك التشفير bidaya 5 2,551 08-07-19, 02:04 AM
آخر رد: elgokr
Information [سؤال] مساعده في التشفير beko mamoun 0 2,135 13-04-15, 01:56 AM
آخر رد: beko mamoun

التنقل السريع :


يقوم بقرائة الموضوع: