|
Luc Pattyn wrote: The only problem seems to be lack of willingness to read it.
I don't think that's the only problem... .45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Cheer up, John; it can't be all that bad.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
You're right... It's worse. .45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
I want to convert a .doc file to .txt file, can some body help me out. I tried with Stream Reader but iam getting Some Junk code in additon to Actual code....
|
|
|
|
|
|
... or read the documentation[^] and implement it yourself.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Hi everybody
What is the best method for storing passwords in SQL database through C# ?Best Regards,
Reza Shojaee
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:08am.
|
|
|
|
|
How can create MD5 hash in C#? Best Regards,
Reza Shojaee
|
|
|
|
|
|
 Don't use MD5 - it is officially "broken". Use SHA instead. Attached the class I use for SHA handling:
using System;
using System.Text;
using System.Security.Cryptography;
using System.Runtime.InteropServices;
using System.Security;
using System.IO;
namespace UtilityControls
{
public class SHA2Hash
{
#region Fields
private byte[] _SHA2Data;
public const int SHA2Bits = 512;
public const int SHA2Bytes = SHA2Bits / 8;
public const int Length = SHA2Bytes * 2;
#endregion
#region Properties
public string SHA2data
{
get
{
StringBuilder sb = new StringBuilder(Length);
foreach (byte b in _SHA2Data)
{
sb.Append(b.ToString("x2"));
}
return sb.ToString();
}
}
#endregion
#region Constructors
public SHA2Hash(Stream s)
{
SHA512 shaM = new SHA512Managed();
_SHA2Data = shaM.ComputeHash(s);
}
public SHA2Hash(SecureString ss)
{
SHA512 shaM = new SHA512Managed();
if (ss != null)
{
IntPtr ptr = Marshal.SecureStringToBSTR(ss);
byte[] bs = Encoding.UTF8.GetBytes(Marshal.PtrToStringAuto(ptr));
_SHA2Data = shaM.ComputeHash(bs);
Marshal.ZeroFreeBSTR(ptr);
}
}
public SHA2Hash(string s)
{
SHA512 shaM = new SHA512Managed();
byte[] bs = Encoding.UTF8.GetBytes(s);
_SHA2Data = shaM.ComputeHash(bs);
}
public SHA2Hash(string s, bool bRestore)
{
if (!bRestore)
{
throw new ApplicationException("Invalid Restore Constructor parameter");
}
if (s.Length == SHA2Hash.Length)
{
byte[] bytes = new byte[SHA2Hash.SHA2Bytes];
char[] chars = s.ToCharArray();
int i = 0;
while ((i >= 0) && (i < SHA2Hash.SHA2Bytes))
{
if (StaticMethods.IsHex(chars[(i * 2) + 0]) && StaticMethods.IsHex(chars[(i * 2) + 1]))
{
byte b1 = StaticMethods.ByteHex(chars[(i * 2) + 0]);
byte b2 = StaticMethods.ByteHex(chars[(i * 2) + 1]);
bytes[i] = (byte) ((b1 << 4) | b2);
i++;
}
else
{
i = -1;
}
}
if (i > 0)
{
_SHA2Data = bytes;
return;
}
}
throw new ApplicationException("Bad restore hash data");
}
public SHA2Hash(byte[] bytes)
{
SHA512 shaM = new SHA512Managed();
_SHA2Data = shaM.ComputeHash(bytes);
}
public SHA2Hash(char[] chars)
{
SHA512 shaM = new SHA512Managed();
byte[] bs = Encoding.UTF8.GetBytes(chars);
_SHA2Data = shaM.ComputeHash(bs);
}
#endregion
#region Overrides
public override int GetHashCode()
{
int hash = 0;
for (int i = 0; i < SHA2Bytes; i += 4)
{
hash ^= StaticMethods.LittleEndian(_SHA2Data[i + 0],
_SHA2Data[i + 1],
_SHA2Data[i + 2],
_SHA2Data[i + 3]);
}
return base.GetHashCode() ^ hash;
}
public override bool Equals(object obj)
{
return (this == (SHA2Hash)obj);
}
#endregion
#region Public methods
public static bool operator ==(SHA2Hash m1, SHA2Hash m2)
{
if ((object)m1 == null)
{
if ((object)m2 == null)
{
return true;
}
}
if (((object)m1 == null) || ((object)m2 == null))
{
return false;
}
for (int i = 0; i < SHA2Bytes; i++)
{
if (m1._SHA2Data[i] != m2._SHA2Data[i])
{
return false;
}
}
return true;
}
public static bool operator !=(SHA2Hash m1, SHA2Hash m2)
{
if ((object)m1 == null)
{
if ((object)m2 == null)
{
return false;
}
}
if (((object)m1 == null) || ((object)m2 == null))
{
return true;
}
for (int i = 0; i < SHA2Bytes; i++)
{
if (m1._SHA2Data[i] != m2._SHA2Data[i])
{
return true;
}
}
return false;
}
#endregion
#region Private Methods
#endregion
}
}
[edit]Forgot to use "Encode...when pasting" option.[/edit]
[edit again]Missed the < of </pre>[/edit again]You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
modified on Saturday, February 27, 2010 7:51 AM
|
|
|
|
|
FYI, looks like you encoded your ending PRE tag. And you may want to specify a lang attribute on that PRE tag (though I'm sure the code will not be looked at... probably just copy/pasted... so perhaps that's a moot point).
|
|
|
|
|
Thanks Griff, just what I need. txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
nice example.
thanks 
|
|
|
|
|
You shouldn't use MD5 for new applications - it is officially "broken". Use SHA-512 instead, as it is currently ok until the SHA-1024 spec is released in 2012. You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Hi please check this link
http://msdn.microsoft.com/en-us/library/system.security.cryptography.md5.aspx
thanks
|
|
|
|
|
Rather than storing the password, store a hash of it. Encrypt and "salt" the password before modifying it to get the hash. Store this hash. Then, when the user enters their password, create the hash from it and compare it to the hash you have stored in the database.
Doing it this way will prevent somebody who gains access to your database from learning any of the passwords, but still gives you the ability to use passwords to secure data and transactions.
|
|
|
|
|
Encrypt it before storing it into the database.Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
|
Hello,
I am trying to make a Remote Desktop Connection software, that does not use the default Windows Remote Desktop, mainly because I want it to work by entering IP's and not domains/names/username etc..
My idea is that the client will capture the screen once and send the image to the server. After that, it will simply take a new screen capture, compare it to the previous one and only send the modified data to the server. The server will know to take the modified that and create the new image from the one he has.
How can this be done? Can anybody show me a sample?
I hope I explained clearly and somebody can help. It's something like a "patch" for a file ...
Language used : C# - Vs 2008
Thanks in advance
|
|
|
|
|
Scrap what you have and Google for "VNCSharp". It's a library that does exactly what you're talking about and will do a far better job and send updates much faster than you can code your version to do the same job.
|
|
|
|
|
Hello,
I already know about VNCSharp, but my problem is that I don't know how to write the server for it.
That's only the client
Any suggestions? If somebody can tell me how to "patch" the files or how can I start to write the VNC server ?
Hope someone can help.
Thanks
|
|
|
|
|
|
I placed a webviewer in my winapp that calls up the isbndatabase and conducts a search. For some reason I constantly get a script error for .js is there anyway to disable javascript so this error will go away or do I need to enable something ?
thanks
|
|
|
|
|
By "webviewer" do you mean "WebBrowser"? If so, there is a property on the WebBrowser to suppress JavaScript errors.
|
|
|
|