RsaCryptoProvider C# export public key in DER format [duplicate] - c#

This question already has answers here:
C# RSA Public Key Output Not Correct
(2 answers)
Closed 4 years ago.
Without using Bouncy Castle - using just C# .NET I need to generate a public/private key pair and send the public key to a service by BASE64 Encoding the key in DER format.
Can anyone help with the export in DER format? I can create the keypair easily enough but the DER format has me stumped.

You could also use OpenSSL
If your server/device requires a different certificate format other
than Base64 encoded X.509, a third party tool such as OpenSSL can be
used to convert the certificates into the appropriate format.
GitHub - OpenSSl.NET

Related

Decode SHA256 to string [duplicate]

This question already has answers here:
Decrypt from SHA256
(3 answers)
Closed 8 months ago.
How can I decode SHA256 in c#?
I tested an online SHA256 Decrypt website and it worked.
Is it possible in c#?
https://10015.io/tools/sha256-encrypt-decrypt
On the website we can read
SHA256 is a hashing algorithm. There is no direct method for SHA256 decryption. SHA256 is decrypted by using Trial & Error methodology. It may take some time if either the text that will be decrypted or the character set that will be used for decryption is long.
Basically a hash function (such as sha256) is irreversible. You cannot retrieve the inputs given a hash (that's why it's widely used for security purposes).
In order to perform a "decryption", you only have one way to go : guess and check. That what the website does [...] SHA256 is decrypted by using Trial & Error methodology [..].

Including encrypted key in url [duplicate]

This question already has answers here:
How to achieve Base64 URL safe encoding in C#?
(10 answers)
Closed 4 years ago.
I have an encrypted url that gets passed in as a query string such as
myurl.com/key/cYtLPBlnOUOi+8413hTQLz+GGeoiLeLhbPuNhK+saqhc/f/FgtKSbcInVB9IIoWER71L1Q6vrnLv8o3eKI843|M==
I am having issues, I believe due to the special characters such as the forward slash. How can I accept this url?
Add a reference to System.Web (Project > References > Add reference > System.Web)
System.Web.HttpUtility.UrlEncode(YOUR_STRING);

Detecting and replacing all smilies in a string [duplicate]

This question already has answers here:
Mysql server does not support 4-byte encoded utf8 characters
(8 answers)
Closed 7 years ago.
I have a integration with facebook and have notice that thay sends for example u+1f600 that is called a grinning face. When I try to store this in the MySQL Text field I get Server does not support 4-byte encoded so a fast solution is to remove all these special chars from the string.
The question is how? I know about the u+1f600 but I suspect that there could be more of them.
Consider switching to MySQL utf8mb4 encoding... https://mathiasbynens.be/notes/mysql-utf8mb4

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

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.

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