Click here to Skip to main content
15,918,889 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: What happens when i Add reference?? Pin
bolly-8117-Jan-09 7:11
bolly-8117-Jan-09 7:11 
GeneralRe: What happens when i Add reference?? Pin
S. Senthil Kumar17-Jan-09 7:19
S. Senthil Kumar17-Jan-09 7:19 
GeneralRe: What happens when i Add reference?? Pin
PIEBALDconsult18-Jan-09 4:40
mvePIEBALDconsult18-Jan-09 4:40 
GeneralRe: What happens when i Add reference?? Pin
Mark Churchill18-Jan-09 13:07
Mark Churchill18-Jan-09 13:07 
GeneralRe: What happens when i Add reference?? Pin
PIEBALDconsult18-Jan-09 15:21
mvePIEBALDconsult18-Jan-09 15:21 
QuestionHow to modify datasource of crystal report at runtime Pin
Ali 11016-Jan-09 20:43
Ali 11016-Jan-09 20:43 
AnswerCross-post Pin
Wendelius16-Jan-09 23:41
mentorWendelius16-Jan-09 23:41 
QuestionSecuring strings in .NET....possibility? Pin
Jon Rista16-Jan-09 15:03
Jon Rista16-Jan-09 15:03 
I have been trying to come up with a way to manage string security in .NET. The whole idea of a SecureString is nice, but the way it works in .NET right now is atrocious...it just doesn't really provide any value given how it is such a pain to work with. I wrote the following extension to System.String...curious what others think:

public static class StringExtensions
{
	const string OVERWRITE_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-=~!@#$%^&*()_+";
	const int MAX_OVERWRITES = 3;

	/// <summary>
	/// Performs a secure wipe of the string in memory, overwriting the 
	/// existing contents with junk, then again with nil.
	/// </summary>
	/// <param name="str">The string to wipe.</param>
	public static unsafe void SecureWipe(this String str)
	{
		// If string is null, there is no securing to be done...return gracefully
		if (str == null)
			return;

		// Prepare
		Random rnd = new Random();
		int maxRnd = OVERWRITE_CHARS.Length;
		int maxLen = str.Length;

		// Pin the string in memory so GC doesn't mess with it, and get a pointer
		fixed (char* c = str)
		{
			// Overwrite with random junk a few times
			for (int r = 0; r < MAX_OVERWRITES; r++)
			{
				for (int i = 0; i < maxLen; i++)
				{
					char rndChar = OVERWRITE_CHARS[rnd.Next(maxRnd)];
					c[i] = rndChar;
				}
			}

			// Overwrite one last time with nil
			for (int i=0; i < maxlen; i++)
                        {
				c[i] = '\0';
			}

			// Set the length to zero
			int* len = (int*)c;
			len[-1] = 0;
		}
	}
}


I know its possible for the .NET framework to create copies of a string in internal framework methods...nothing I can do about that, and when you need to display a string, SecureString doesn't solve that problem either. But at least with something like this...you can wipe the copy that hackers are most likely to get.

Thoughts? Improvements? Reasons why it won't work?
AnswerRe: Securing strings in .NET....possibility? Pin
Wendelius16-Jan-09 23:55
mentorWendelius16-Jan-09 23:55 
GeneralRe: Securing strings in .NET....possibility? Pin
Jon Rista17-Jan-09 7:33
Jon Rista17-Jan-09 7:33 
AnswerRe: Securing strings in .NET....possibility? Pin
Dave Kreskowiak17-Jan-09 2:09
mveDave Kreskowiak17-Jan-09 2:09 
GeneralRe: Securing strings in .NET....possibility? Pin
Jon Rista17-Jan-09 7:32
Jon Rista17-Jan-09 7:32 
AnswerRe: Securing strings in .NET....possibility? Pin
PIEBALDconsult17-Jan-09 3:50
mvePIEBALDconsult17-Jan-09 3:50 
GeneralRe: Securing strings in .NET....possibility? Pin
Jon Rista17-Jan-09 7:31
Jon Rista17-Jan-09 7:31 
GeneralRe: Securing strings in .NET....possibility? Pin
supercat919-Jan-09 6:14
supercat919-Jan-09 6:14 
GeneralRe: Securing strings in .NET....possibility? Pin
Jon Rista19-Jan-09 6:53
Jon Rista19-Jan-09 6:53 
AnswerRe: Securing strings in .NET....possibility? Pin
ssclaire17-Jan-09 4:45
ssclaire17-Jan-09 4:45 
GeneralRe: Securing strings in .NET....possibility? Pin
Jon Rista17-Jan-09 7:29
Jon Rista17-Jan-09 7:29 
QuestionTabStop for Listbox Pin
bobbymale7716-Jan-09 12:41
bobbymale7716-Jan-09 12:41 
AnswerRe: TabStop for Listbox Pin
Wendelius16-Jan-09 23:44
mentorWendelius16-Jan-09 23:44 
AnswerRe: TabStop for Listbox Pin
bobbymale7717-Jan-09 10:54
bobbymale7717-Jan-09 10:54 
GeneralRe: TabStop for Listbox Pin
Wendelius18-Jan-09 0:28
mentorWendelius18-Jan-09 0:28 
GeneralRe: TabStop for Listbox Pin
bobbymale7719-Jan-09 0:50
bobbymale7719-Jan-09 0:50 
QuestionClickOnce rant Pin
RugbyLeague16-Jan-09 3:50
RugbyLeague16-Jan-09 3:50 
AnswerRe: ClickOnce rant Pin
Eddy Vluggen18-Jan-09 0:44
professionalEddy Vluggen18-Jan-09 0:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.