|
I don't have a conversion for some of the Java types you're using, but the following syntax should be correct:
public static string Dcipher(string encryptedText1)
{
try
{
sbyte[] desKeyData = {(sbyte) 0x01, (sbyte) 0x02, (sbyte) 0x03, (sbyte) 0x04, (sbyte) 0x05, (sbyte) 0x06, (sbyte) 0x07, (sbyte) 0x08};
DESKeySpec desKeySpec = new DESKeySpec(desKeyData);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
SecretKey key = null;
try
{
key = keyFactory.generateSecret(desKeySpec);
}
catch (InvalidKeySpecException ex1)
{
}
sbyte[] initVector = new sbyte[] {0x10, 0x10, 0x01, 0x04, 0x01, 0x01, 0x01, 0x02};
AlgorithmParameterSpec algParamSpec = new IvParameterSpec(initVector);
Cipher m_decrypter = Cipher.getInstance("DES/OFB32/NoPadding");
m_decrypter.init(Cipher.DECRYPT_MODE, key, algParamSpec);
sbyte[] encryptedText = encryptedText1.Bytes;
sbyte[] decryptedText = m_decrypter.doFinal(encryptedText);
return (new string(decryptedText));
}
catch (BadPaddingException ex)
{
Console.WriteLine(ex.ToString());
Console.Write(ex.StackTrace);
}
catch (IllegalBlockSizeException ex)
{
Console.WriteLine(ex.ToString());
Console.Write(ex.StackTrace);
}
catch (InvalidAlgorithmParameterException ex)
{
Console.WriteLine(ex.ToString());
Console.Write(ex.StackTrace);
}
catch (InvalidKeyException ex)
{
Console.WriteLine(ex.ToString());
Console.Write(ex.StackTrace);
}
catch (NoSuchPaddingException ex)
{
Console.WriteLine(ex.ToString());
Console.Write(ex.StackTrace);
}
catch (NoSuchAlgorithmException ex)
{
Console.WriteLine(ex.ToString());
Console.Write(ex.StackTrace);
}
return "";
}
Dave Doknjas
Convert between VB, C#, C++, & Java
www.tangiblesoftwaresolutions.com
Instant C# - VB to C# Converter
Instant VB - C# to VB Converter
|
|
|
|
|
I am getting a timeout message when accessing a linq to sql object in a C# 2010 application. This error message is occuring when I am doing a select in the linq to sql object. thus can you tell me how I can increase the timeout on the linq to sql data set object? The following os the error message I am getting:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
2013-01-24 16:40:03.3082|ERROR|Sample|************* Stack Trace *******************
2013-01-24 16:40:03.3238|ERROR|Sample| at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)
at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)
at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
at System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)
at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)
|
|
|
|
|
You may be causing the exception yourself, if it happens after a period of time or after a number of connection attempts. Try reading this[^] for a brief discussion on the topic.
If it's the first connection attempt your code makes to the database, you've got a problem with your connection string or the database engine isn't responding for some reason or ...
|
|
|
|
|
How is this question different than the one that you posted 3 days ago?
|
|
|
|
|
1. You already posted a similar question a while back. I suggested logging. Did you implement that? Logging a stack trace is not enough.
2. Try setting a break point in the catch that generates this message and check your variables. In LINQ you should be able to retreive the SQL that is sent to the database, find it and try to execute in SQL Server directly. If necessary, type it over in the SQL manager by hand.
3. A timeout is there for a reason, you should only increase the timeout if you're absolutely certain that procedure is lengthy. Honestly, based on your questions I don't think that is the case here. increasing the timeout could at best, be a workaround, not a solution.
|
|
|
|
|
hi dears...
i want the activity-selection algorithm in c#.
thanks for u...
|
|
|
|
|
There are many ways to select an activity. If you have a problem with some code you have written, feel free to post a question on it. Good luck.
|
|
|
|
|
sorry, my meaning was activity-selection algorithm that is greedy algorithm in C#. i have a project for university, i thanks so much if u help me.
best regards...
|
|
|
|
|
So you're trying to get me to pass your course. If you can't solve this, how do you expect to do this as a career?
|
|
|
|
|
I'm assuming you're talking about this[^]. Start there and write your own code. It's what you're going to school for or getting paid to write isn't it?? Either way, we're not writing your code for you.
|
|
|
|
|
sorry, my meaning was activity-selection algorithm that is greedy algorithm in C#. i have a project for university, i thanks so much if u help me.
best regards...
|
|
|
|
|
The whole point behind you getting these assignments is for YOU to demonstrate that you can applied what you've learned. It's NOT for us to do the work for you.
|
|
|
|
|
Here's an activity selection algorithmm coded in C# - probably not what you want.
But you have not explained what you want.
static void Main(string[] args)
{
Random rndGen = new Random();
var activities = new List<string>() { "bake bread", "mow lawn", "read book", "sleep", "don batman costume", "sneeze",
"have a beer", "code furiously", "make excuse for late assignment", "plead for help"};
for (int i = 0; i < 3; i++)
{
int act = rndGen.Next(activities.Count);
Console.WriteLine((i+1).ToString() + ". " + activities[act]);
}
Console.ReadLine();
}
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
The only valid measurement of code quality: WTFs/minute.
|
|
|
|
|
I think maybe a command line parser is in order.
|
|
|
|
|
mazizi0 wrote: hi dears... Hello luvver
mazizi0 wrote: i want the activity-selection algorithm in c#. Oooh, ooh I know this game. I want a Porsche.
mazizi0 wrote: thanks for u... No no. Thanks for YOU!
|
|
|
|
|
So what are you going to do when (if) you pass your course & get a job?
Ask your fellow employees to do your work for you, then take the credit for it?
How long do you think you'd last in that job?
Man up - put a bit of effort in and do it yourself or you're on a slippery slope to nowhere career-wise.
|
|
|
|
|
In a C# 2010 windows application that I am writing, I am accessing excel 2010 spreadsheets. I am obtaining information about the data contained within the excel spreadsheet from the file name.
My problem occurs when an excel spreadsheet has been openend and not closed properly by the application. The program actually aborts. When I try to access these particular spreadsheets again, there is a try call error that occurs.
Is there some code I can write to check to make certain the excel spreadsheet is ok and there is no problem with the file? If so, can you show me the code and/or point me to a link that will show me how to solve this problem?
|
|
|
|
|
dcof wrote: Is there some code I can write to check to make certain the excel spreadsheet is ok and there is no problem with the file? Quite possibly, but you need to provide much more detail about the actual problem that is occurring, for anyone to be able to make any useful suggestions.
|
|
|
|
|
Is there code to check the excel file to see if it's OK?
No, not really.
You need to write your code to handle the situation where it's not. This includes properly wrapping sensitive sections of your code that deals with opening, reading, and closing the Excel file and properly handling those exceptions according to your business rules for processing the file.
|
|
|
|
|
hello, i have a service in WCF that wil recieve a alrge xml in response. here is my config
<bindings>
<basicHttpBinding>
<binding name="CVSCValidateContactAlertSOAP" />
<binding name="CVSCUpdateOperationsContactSOAP" />
<binding name="ContactRegisterSOAP" />
<binding name="FindContactsListSOAP" />
<binding name="FindReviewsByAccountSOAP" />
<binding name="AddReviewSOAP" />
<binding name="ProductOfferingSOAP" />
<binding name="OperationSupportSOAP" maxBufferPoolSize="2147483647"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
transferMode="Streamed">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
<binding name="CustomerAccountSOAP" maxBufferPoolSize="2147483647"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
transferMode="Streamed">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
<binding name="BusinessInteractionSOAP" />
</basicHttpBinding>
</bindings>
the answer from the server is
Server stack trace:
en System.ServiceModel.Channels.HttpInput.ThrowMaxReceivedMessageSizeExceeded()
en System.ServiceModel.Channels.HttpInput.GetMessageBuffer()
en System.ServiceModel.Channels.HttpInput.ReadBufferedMessage(Stream inputStream)
en System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(HttpRequestMessage httpRequestMessage, Exception& requestException)
en System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
en System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
en System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
en System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
en System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
en System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
en System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
en System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
en IServicioCuenta.buscarCuenta(Auditoria auditoria, CriterioSeleccion criterio)
en ServicioCuentaClient.buscarCuenta(Auditoria auditoria, CriterioSeleccion criterio)
|
|
|
|
|
|
|
I found this SHARE_INFO_503 structure (Windows)[^] which uses the same value names, but in this documentation the actual values are mentioned.
0100000101101110011001000111001011101001
|
|
|
|
|
At the bottom of that MSDN document, you'll see it says "Header: Lmshare.h (include Lm.h)".
Searching the header files listed in Lm.h for one of the values will lead you to LMaccess.h. The values start on line 1250 of that file:
#define ACCESS_NONE 0
#define ACCESS_ALL ( ACCESS_READ | \
ACCESS_WRITE | \
ACCESS_CREATE | \
ACCESS_EXEC | \
ACCESS_DELETE | \
ACCESS_ATRIB | \
ACCESS_PERM \
)
#define ACCESS_READ 0x01
#define ACCESS_WRITE 0x02
#define ACCESS_CREATE 0x04
#define ACCESS_EXEC 0x08
#define ACCESS_DELETE 0x10
#define ACCESS_ATRIB 0x20
#define ACCESS_PERM 0x40
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I am looking for a solution by which i type some keyword and get the list of url which contain that world
|
|
|
|
|