See Also: AvoidLocalDataStoreSlotRule Members
Example
static void SetSharedKey (byte[] key) { LocalDataStoreSlot lds = Thread.AllocateNamedDataSlot ("shared-key"); lds.SetData (key.Clone ()); } public byte[] SignData (byte[] data) { LocalDataStoreSlot lds = Thread.GetNamedDataSlot ("shared-key"); using (HMACSHA1 hmac = new HMACSHA1 (Thread.GetData (lds) as byte[])) { return hmac.ComputeHash (data); } }
Example
[ThreadStatic] static byte[] shared_key; static void SetSharedKey (byte[] key) { shared_key = (byte[]) key.Clone (); } public byte[] SignData (byte[] data) { using (HMACSHA1 hmac = new HMACSHA1 (shared_key)) { return hmac.ComputeHash (data); } }