Why does RSACryptoServiceProvider.SignHash have a "hash algorithm identifier" parameter? [duplicate] - c#

This question already has answers here:
Why does SignHash need to know what hash algorithm was used?
(2 answers)
Closed 9 years ago.
Since RSACryptoServiceProvider.SignHash signs an already hashed message - why does it need to know which hash algorithm was used?

It seems that in order to make the signature more useful to the recipient, the OID of the hashing algorithm that was used is included in the signature (per PKCS1). That way, it does not have to be communicated separately.

Related

Shortening GUIDS whil Maintaining Uniqueness [duplicate]

This question already has answers here:
YouTube-like GUID
(9 answers)
Closed 7 years ago.
Is it possible to the Hash or digest of a GUID so it is shorter in length while maintaining it's uniqueness?
No. A GUID needs all 128 bits to be globally unique. The bits describe the time, location, and uniqueness identifier (an incrementing key used to prevent the same GUID from being generated if the clock hasn't moved or has been artificially manipulated).
If you have some requirement short of global uniqueness, then yes, you can create locally unique identifiers that are less than 128 bits. There are likely better ways to do this than generating a 128 bit GUID and then coming up with some kind of awesome hashing algorithm that maintains pretty good uniqueness at less than 128 bits.

Making email as primary key is bad idea? [duplicate]

This question already has answers here:
Use email address as primary key?
(25 answers)
Closed 7 years ago.
I am making an application in which users may create their accounts. I make user email as primary key in user's table. Is this technique is really bad technique? Should I create auto increment integer as primary key?
Yes, it is a terrible idea. An email is something long (so your key is longer than necessary), and it isn't immutable. I've changed at least three emails in the last ten years (providers closed).

YouTube Unique Identifier [duplicate]

This question already has answers here:
YouTube URL algorithm?
(11 answers)
Closed 3 years ago.
I noticed on YouTube their keys look like this "BwgT06NY1FE". I was just wondering how is this type of key created? Is this based on a GUID?
This is most likely Base36. All letters and numbers. It's pretty common, because you can use a "SERIAL" in a database and just increment it, and then just parse from Base36 in your URL.
It makes for nice URLs (bit.ly also uses this format), but has some drawbacks. Ie, you wouldn't want to use it for any sort of private data because people can just type in a random number and get a result (it's unlikely someone could guess a GUID in use by your database unless they try a few billion)..

How to read Hash Parameters in Url [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
How to get Url Hash (#) from server side
I have hash parameters in url
Can any body please help me to how to read Hash parameters value from Url using C#?
www.example.com/default.aspx#!type=1
How to read value of type?
The hash part is only used and available on the client. You cannot read it from ASP.NET / C#.
Split the URL at the hash (#).
Then split the second element from above at each ampersand (&)
Then split each of those at the equals (=) sign.
You will then have all the parameters and values.
If this was asking about a ASP.net application, you want to use Request.QueryString["type"] to get the value.

Excellent Encryption for String Type Data [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
How to encrypt a string in .NET?
Which one is the most excellent and toughest encryption for String type data in C#..
That really depends on your exact requirements.
Most modern encryption algorithms are probably more than strong enough for your needs if you use them properly.
The weak point in your system will not be the encryption algorithm itself. Almost every other aspect of your setup will be more vulnerable to attack than the algorithm.
My primary answer is "it depends upon what you're doing with that string". This question (and answers) will guide you...
.NET Secure Memory Structures
... but it depends if you're encyrpting/security that string in memory, how you're persisting it, how you intend using that string and how you intend disposing of it.
These SO questions touch on these topics too..
How to encrypt a string in .NET?
What's the best way to encrypt short strings in .NET?
... and contain useful links.
That would be a one-time pad. If correctly implemented it's been proved to be impossible to crack but an OTP is most probably not a viable option for you.
RSA encryption is very secure and .NET supports it. But since asymmetric encryption is only designed for encrypting data smaller than it's key size it's often not a great choice for encryption of arbitrary strings. That leads us to block ciphers and among those I would recommend AES.

Categories