|
OK.
This[^] article suggests BinaryDataContractSerializer may be the way to go. Not sure if you'd already seen this.
/ravi
|
|
|
|
|
Thanks - i'll look into it
|
|
|
|
|
hi
how to call web api passing multiple parameters in c#
|
|
|
|
|
From where: desktop application, web page ... ?
Please give some proper detail about your problem.
|
|
|
|
|
Hi
I want to call web api from desktop application .
For that I use readasync method . Using readasync method, pass multiple parameters as a concatenated string. In webapi I split that string in to multiple parameters. How can I pass multiple parameters from c# application?
|
|
|
|
|
You already answered your own question.
|
|
|
|
|
I have one function witch check signature.
public static bool CheckSignature(string key64, string sig64)
{
var key = Convert.FromBase64String(key64);
var sig = Convert.FromBase64String(sig64);
var rsa = new RSACryptoServiceProvider(new CspParameters
{
Flags = CspProviderFlags.UseMachineKeyStore
});
rsa.FromXmlString("<RSAKeyValue><Modulus>4IlzOY3Y9fXoh3Y5f06wBbtTg94Pt6vcfcd1KQ0FLm0S36aGJtTSb6pYKfyX7PqCUQ8wgL6xUJ5GRPEsu9 gyz8ZobwfZsGCsvu40CWoT9fcFBZPfXro1Vtlh/xl/yYHm+Gzqh0Bw76xtLHSfLfpVOrmZdwKmSFKMTvNXOFd0V18=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>");
var def = new RSAPKCS1SignatureDeformatter();
def.SetKey(rsa);
def.SetHashAlgorithm("MD5");
return def.VerifySignature(key, sig);
}
Now i need to create signature for one of my keys.
public static byte[] CreateSignature(string key64)
{
var data = Convert.FromBase64String(key64);
var rSaCryptoServiceProvider = new RSACryptoServiceProvider(new CspParameters
{
Flags = CspProviderFlags.UseMachineKeyStore
});
rSaCryptoServiceProvider.FromXmlString("<RSAKeyValue><Modulus>4IlzOY3Y9fXoh3Y5f06wBbtTg94Pt6vcfcd1KQ0FLm0S36aGJtTSb6pYKfyX7PqCUQ8wgL6xUJ5GRPEsu9 gyz8ZobwfZsGCsvu40CWoT9fcFBZPfXro1Vtlh/xl/yYHm+Gzqh0Bw76xtLHSfLfpVOrmZdwKmSFKMTvNXOFd0V18=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>");
var RSAform = new RSAPKCS1SignatureFormatter();
RSAform.SetKey(rSaCryptoServiceProvider);
RSAform.SetHashAlgorithm("MD5");
byte[] hashData = CalculateMD5Hash(data);
return RSAform.CreateSignature(hashData);
}
But im getting an exception "Keyset does not exist" on "RSAform.CreateSignature(hashData)" line.
Any suggestion?
Still amater
|
|
|
|
|
RSA keys are in pairs, but you used public key in both methods. replacing provided key in CheckSignature with private key should solve your problem.
and in CheckSignature method you should feed VerifySignature with MD5 hash of key varibale, the code should be more like this
public static byte[] CreateSignature(string key64)
{
var data = Convert.FromBase64String(key64);
var rSaCryptoServiceProvider = new RSACryptoServiceProvider(new CspParameters
{
Flags = CspProviderFlags.UseMachineKeyStore
});
rSaCryptoServiceProvider.FromXmlString(privateKey);
var RSAform = new RSAPKCS1SignatureFormatter();
RSAform.SetKey(rSaCryptoServiceProvider);
RSAform.SetHashAlgorithm("MD5");
var md5 = MD5.Create();
byte[] hashData = md5.ComputeHash(data);
return RSAform.CreateSignature(hashData);
}
hope this helps
|
|
|
|
|
How can i benefit from SQL CLR C# stored procedure or any item like this in SQL Server Project vi vs2013...I need some information about the benefit and use of this project in windows application project.Please i need an overview about this type of project and what its usefulnes....Thank you
|
|
|
|
|
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.
Try it yourself, you may find it is not as difficult as you think!
I'm pretty sure your tutor wants to know what you think about this, not what I think...
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
I'm pretty sure that you could Google this, the pros and cons of CLR stored procedures can easily be found.
|
|
|
|
|
I am attempting to rewrite a program using SqlCE database vs an OleDb database. The code below worked using OleDb, but now throws a System.Argument exception.
SqlCeCommand GetAcctsCmd = new SqlCeCommand("SELECT ACCTSTORE, ACCTMGR, Count(ACCTMGR) AS [CountOfACCTMGR] FROM ALLACCOUNTS WHERE (DATEDIFF(d, ACCTNEXTDUE, @TESTDATE) > 0 )";
GetAcctsCmd.Parameters.Add("@TESTDATE", SqlDbType.DateTime);
GetAcctsCmd.Parameters["@TESTDATE"].Value = dtPD;
The exception is being thrown on the last line of code above. dtPD is a DateTime.
What am I missing?
Thanks in advance.
Jude
|
|
|
|
|
A close bracket...
SqlCeCommand GetAcctsCmd = new SqlCeCommand("SELECT ACCTSTORE, ACCTMGR, Count(ACCTMGR) AS [CountOfACCTMGR] FROM ALLACCOUNTS WHERE DATEDIFF(d, ACCTNEXTDUE, @TESTDATE) > 0 ");
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Sorry, I missed that on my cut and paste. The close bracket is there.
Jude
|
|
|
|
|
I would be curious to know your copy & paste technic, then
while (!working) {
Reboot();
}
|
|
|
|
|
What version of the SqlCE libraries are you using, and what's the exception message?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Ver 3.5.1, Runtime ver 2.0.50727
Message=System.ArgumentException: Date
Jude
|
|
|
|
|
Isn't there also a message description that tells details? I've never seen an exception that just says "Date".
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Are you sure you're passing SqlDbType.DateTime to the Parameters.Add method, and not SqlDbType.Date ? The only place I can see that would throw an ArgumentException with a message of "Date" is if you're passing an unsupported SqlDbType value in:
internal static SqlCeType FromSqlDbType(SqlDbType type)
{
for (int index = 0; index < SqlCeType._AllTypes.Length; ++index)
{
if (type == SqlCeType._AllTypes[index].SqlDbType)
return SqlCeType._AllTypes[index];
}
throw new ArgumentException(type.ToString());
}
This error message has been improved in v4 of the SqlServerCe library.
If that's not the problem, can you post the stack-trace of the exception?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Are you sure that dtPD is a DateTime? Or is it rather a DateTimePicker? Or a string conatining a formatted datetime value?
|
|
|
|
|
|
|
|
|