Back to "أكثر في رحلتي إلى عالم رائع من ASP.net."

This is a viewer only at the moment see the article on how this works.

To update the preview hit Ctrl-Alt-R (or ⌘-Alt-R on Mac) or Enter to refresh. The Save icon lets you save the markdown file to disk

This is a preview from the server running through my markdig pipeline

ASP.NET Imported mostlylucidcouk Security

أكثر في رحلتي إلى عالم رائع من ASP.net.

Sunday, 29 February 2004

كتبت في الوظائف السابقة أنّي كنتُ أخطط أن أحظى بجولة حول هناك أخبار جيدة و سيئة لهذه الخطة. يبدو (بشكل عادي) أن مادة MAC والتشفير يتم التعامل معها في الواقع في فئة LOSWriter؛ صنف داخلي يستخدم من قبل في الواقع إلى إلى فعّل كائن متسلسل الإيطالية استخدام الشفرة التالية للقيام بهذا (يشكر مرة أخرى مرة أخرى إلى لا يمكن ) :

internal void CompleteTransforms(TextWriter output, bool enableMac, byte[] macKey)
{ int num1;
byte[] array1;
string text1;
char[] array2;
string text2;
num1 = 0;
if (this._recyclable)
{
 this._byteBuffer = ((byte[]) LosWriter._byteBufferAllocator.GetBuffer());
if (this._freePos > 0)
{
 num1 = Encoding.UTF8.GetBytes(this._charBuffer, 0, this._freePos, this._byteBuffer, 0);
 
}
if (enableMac)
{
 array1 = MachineKey.GetEncodedData(this._byteBuffer, macKey, 0, &(num1));
text1 = Convert.ToBase64String(array1, 0, num1);
output.Write(text1);
return; 
}
array2 = ((char[]) LosWriter._charBufferAllocatorBase64.GetBuffer());
num1 = Convert.ToBase64CharArray(this._byteBuffer, 0, num1, array2, 0);
output.Write(array2, 0, num1);
LosWriter._charBufferAllocatorBase64.ReuseBuffer(array2);
return; 
}
this._byteBuffer = Encoding.UTF8.GetBytes(this._charBuffer, 0, this._freePos);
num1 = this._byteBuffer.Length;
if (enableMac)
{
 this._byteBuffer = MachineKey.GetEncodedData(this._byteBuffer, macKey, 0, &(num1));
 
}
text2 = Convert.ToBase64String(this._byteBuffer);
output.Write(text2);
 
}

كما ترون، هذا الرمز يتعامل مع تطبيق مفتاح MAC و تشفير إلى البيانات المتسلسلة. هذا هو الرمز المستخدم من قبل 'MachineKey' لأداء التشفير:

internal static byte[] EncryptOrDecryptData(bool fEncrypt, byte[] buf, byte[] modifier, int start, int length)
{ MemoryStream stream1;
ICryptoTransform transform1;
CryptoStream stream2;
byte[] array1;
byte[] array2;
MachineKey.EnsureConfig();
stream1 = new MemoryStream();
transform1 = MachineKey.GetCryptoTransform(fEncrypt);
stream2 = new CryptoStream(stream1, transform1, 1);
stream2.Write(buf, start, length);
if (fEncrypt && (modifier != null))
{
 stream2.Write(modifier, 0, modifier.Length);
 
}
stream2.FlushFinalBlock();
array1 = stream1.ToArray();
stream2.Close();
MachineKey.ReturnCryptoTransform(fEncrypt, transform1);
if (!fEncrypt && (modifier != null))
{
 array2 = new byte[((uint) (array1.Length - modifier.Length))];
Buffer.BlockCopy(array1, 0, array2, 0, array2.Length);
array1 = array2;
 
}
return array1; 
} 

لسوء الحظ، هذا يعني أنه إما أن ألعب عن طريق الإنعكاس / رمي المصدر من Refelector / تماماً إعادة اختراع كيف يعمل هذا ليذهب إلى أبعد من ذلك بكثير مع بلدي Piew State tenkering،

أنا في نهاية المطاف سوف تضطر إلى إعادة الترجيح وكتابة مقالة واحدة من هذه الأيام... مشكلة بالنسبة لي هو هيكلة الشيء لذلك فإنه يمكن قراءته إلى البشر غير الهمجيين...

logo

© 2026 Scott Galloway — Unlicense — All content and source code on this site is free to use, copy, modify, and sell.