|
Then just look at the recent postings. I bet you don't have to go many pages back to find a post with the subject "PLEEEEASE ANSWER MY QUESTION!!! VERY URGENT!!!!!!!!!".
---
b { font-weight: normal; }
|
|
|
|
|
|
comeon guys help me please... I helped alot in the past two days (well at-least tryed my best to help), please just with these two problems help me very quick, I have no-one else to turn to, and I need it fast, I can't read 5 articles right now.
|
|
|
|
|
NaNg, calm down and think logically. You seem to believe that everyone has developed an ICryptoTransform. If that were the case you would have found infinite examples on the internet. If you don't believe me do a Google for internet chat program code.
I have no idea how to develop an ICryptoTransform or I would gladly help you.
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
leppie does and he is not telling =\
so atleast the other question, about the settings... I don't need it to be password protected, I just need it to be protected, so it can't be seen as plain english...
oh and another thing, if I use the VC# Express publisher, how can I retrive the installation path? (I want to put a link on startup folder to the file)
|
|
|
|
|
NaNg15241 wrote: I just need it to be protected, so it can't be seen as plain english...
see this previous thread[^]
NaNg15241 wrote: if I use the VC# Express publisher, how can I retrive the installation path?
Never used it. Does it create a MSI (Windows Installer)? Windows Installer will have the installation path and provides mechanisms for creating startup entries. I don't know how to use it to create a shortcut to a folder.
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
so in the visual studio, I have a settings tab, now I can write here some non-importent stuff, but I need more info about user\application scope, what does it mean? does application means for this run or all runs? does user mean for this application run, all application run, windows etc...
|
|
|
|
|
NaNg15241 wrote: but I need more info about user\application scope, what does it mean?
Did you look at the documentation? There is a link to documentation on the settings editor:
"Learn more about application settings..."
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
yes I have, still didn't get a word...
I hate MSDN, they don't know how to explain stuff...
|
|
|
|
|
NaNg15241 wrote: I hate MSDN, they don't know how to explain stuff...
Really? I'll concede they don't always provide the best documentation, but generally MSDN is sufficient. For example, on your TransformBlock method, they give the following information on the parameters:
inputBuffer
The input on which to perform the operation on.
inputOffset
The offset into the input byte array from which to begin using data from.
inputCount
The number of bytes in the input byte array to use as data.
outputBuffer
The output to which to write the data to.
outputOffset
The offset into the output byte array from which to begin writing data from.
Return Value
The number of bytes written.
Honestly, that's not bad documentation. They're telling you what each parameter is in order that you can call the function with some understanding of what's going on. Now, if you don't understand bytes, arrays, or the meanings of the terms used in the documentation, then you need to study the entire class to get a better understanding of the context.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Islamic Domination: Coming to a Jewish state near you!
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
so what do I do with the outputbuffer? as I understand this method returns how many bytes are writen, so why do i need to output buffer and offset?
|
|
|
|
|
|
From the documentation:
Transforms the specified region of the input byte array and copies the resulting
transform to the specified region of the output byte array.
Perfectly clear. If you are having trouble understanding this it is not the fault of the documentation.
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
|
already saw them all even before, none of them does help becuase it doesn't tell me how to create MY OWN ICryptoTransform class, it just say how to use the cryptostream.
|
|
|
|
|
You gonna need to read up on a bit more than that! All the info is provided in MSDN. You will definately need to read up on cryptography as you need good knowledge how ciphering modes and padding works with stream ciphers. I have done this myself, and it isnt very hard.
|
|
|
|
|
so why can't you explain a little of that?
share that little of knoladge I need to get things starting... I'm corrently stuck in my project just because of this.
|
|
|
|
|
It's not that I dont want to explain it, it means it's going to take long. I have uploaded my experiments to ftp://ftp.uunet.co.za/pub/incoming/CryptoTests.zip (and no clickety, use a decent FTP client or DL manager).
|
|
|
|
|
Here's something that should help:
<FONT color=Blue>public abstract class</FONT> GenericTransform : SymmetricAlgorithm, ICryptoTransform
{
<FONT color=Blue>static readonly</FONT> RandomNumberGenerator RANDOM = RandomNumberGenerator<FONT color=DarkBlue>.</FONT>Create<FONT color=DarkBlue>()</FONT>;
<FONT color=Blue>static readonly</FONT> HashAlgorithm HASH = HashAlgorithm<FONT color=DarkBlue>.</FONT>Create<FONT color=DarkBlue>()</FONT>;
TransformMode curmode = TransformMode<FONT color=DarkBlue>.</FONT>None;
<FONT color=Blue>byte</FONT><FONT color=DarkBlue>[]</FONT> initial_iv;
<FONT color=Blue>protected enum</FONT> TransformMode
{
None, Encrypt, Decrypt
}
<FONT color=Blue>protected</FONT> TransformMode CurrentMode
{
<FONT color=Blue>get</FONT> {<FONT color=Blue>return</FONT> curmode;}
<FONT color=Blue>set</FONT> {curmode = <FONT color=Blue>value</FONT>;}
}
<FONT color=Blue>protected</FONT> GenericTransform<FONT color=DarkBlue>()</FONT>
{
<FONT color=DarkGreen>
BlockSizeValue = <FONT color=Red>64</FONT>;
KeySizeValue = <FONT color=Red>128</FONT>;
PaddingValue = PaddingMode<FONT color=DarkBlue>.</FONT>PKCS7;
LegalKeySizesValue = <FONT color=Blue>new</FONT> KeySizes<FONT color=DarkBlue>[]</FONT>{ <FONT color=Blue>new</FONT> KeySizes<FONT color=DarkBlue>(</FONT>KeySizeValue,KeySizeValue,<FONT color=Red>0</FONT><FONT color=DarkBlue>)</FONT> };
LegalBlockSizesValue = <FONT color=Blue>new</FONT> KeySizes<FONT color=DarkBlue>[]</FONT>{ <FONT color=Blue>new</FONT> KeySizes<FONT color=DarkBlue>(</FONT>BlockSizeValue,BlockSizeValue,<FONT color=Red>0</FONT><FONT color=DarkBlue>)</FONT> };
}
<FONT color=DarkGreen>
<FONT color=Blue>int</FONT> ICryptoTransform<FONT color=DarkBlue>.</FONT>InputBlockSize
{
<FONT color=Blue>get</FONT> { <FONT color=Blue>return</FONT> BlockSizeValue/<FONT color=Red>8</FONT>; }
}
<FONT color=DarkGreen>
<FONT color=Blue>public abstract int</FONT> OutputBlockSize {<FONT color=Blue>get</FONT>;}
<FONT color=Blue>public abstract int</FONT> TransformBlock<FONT color=DarkBlue>(</FONT><FONT color=Blue>byte</FONT><FONT color=DarkBlue>[]</FONT> inputBuffer, <FONT color=Blue>int</FONT> inputOffset, <FONT color=Blue>int</FONT> inputCount, <FONT color=Blue>byte</FONT><FONT color=DarkBlue>[]</FONT> outputBuffer, <FONT color=Blue>int</FONT> outputOffset<FONT color=DarkBlue>)</FONT>;
<FONT color=Blue>public byte</FONT><FONT color=DarkBlue>[]</FONT> TransformFinalBlock<FONT color=DarkBlue>(</FONT><FONT color=Blue>byte</FONT><FONT color=DarkBlue>[]</FONT> inputBuffer, <FONT color=Blue>int</FONT> inputOffset, <FONT color=Blue>int</FONT> inputCount<FONT color=DarkBlue>)</FONT>
{
<FONT color=Blue>byte</FONT><FONT color=DarkBlue>[]</FONT> outputBuffer = <FONT color=Blue>null</FONT>;
<FONT color=Blue>bool</FONT> enc = curmode <FONT color=DarkBlue>==</FONT> TransformMode<FONT color=DarkBlue>.</FONT>Encrypt;
<FONT color=Blue>if</FONT> <FONT color=DarkBlue>(</FONT>PaddingValue <FONT color=DarkBlue>==</FONT> PaddingMode<FONT color=DarkBlue>.</FONT>None<FONT color=DarkBlue>)</FONT>
{
outputBuffer = <FONT color=Blue>new byte</FONT>[inputCount];
}
<FONT color=Blue>else</FONT>
{
outputBuffer = <FONT color=Blue>new byte</FONT>[OutputBlockSize];
<FONT color=Blue>if</FONT> <FONT color=DarkBlue>(</FONT>enc<FONT color=DarkBlue>)</FONT>
{
<FONT color=DarkGreen>
<FONT color=Blue>byte</FONT> pad = <FONT color=DarkBlue>(</FONT><FONT color=Blue>byte</FONT><FONT color=DarkBlue>)(</FONT>OutputBlockSize - inputCount<FONT color=DarkBlue>)</FONT>;
<FONT color=Blue>for</FONT> <FONT color=DarkBlue>(</FONT><FONT color=Blue>int</FONT> i = inputCount; i < OutputBlockSize; i<FONT color=DarkBlue>++)</FONT>
{
inputBuffer[i] = <FONT color=DarkBlue>(</FONT>PaddingValue <FONT color=DarkBlue>==</FONT> PaddingMode<FONT color=DarkBlue>.</FONT>PKCS7 ? pad : <FONT color=DarkBlue>(</FONT><FONT color=Blue>byte</FONT><FONT color=DarkBlue>)</FONT><FONT color=Red>0</FONT><FONT color=DarkBlue>)</FONT>;
}
}
}
<FONT color=Blue>int</FONT> c = TransformBlock<FONT color=DarkBlue>(</FONT>inputBuffer, inputOffset, outputBuffer<FONT color=DarkBlue>.</FONT>Length, outputBuffer, <FONT color=Red>0</FONT><FONT color=DarkBlue>)</FONT>;
<FONT color=Blue>byte</FONT><FONT color=DarkBlue>[]</FONT> final = <FONT color=Blue>null</FONT>;
<FONT color=Blue>if</FONT> <FONT color=DarkBlue>(</FONT>PaddingValue <FONT color=DarkBlue>==</FONT> PaddingMode<FONT color=DarkBlue>.</FONT>None<FONT color=DarkBlue>)</FONT>
{
final = <FONT color=Blue>new byte</FONT>[inputCount];
}
<FONT color=Blue>else</FONT>
{
<FONT color=Blue>if</FONT> <FONT color=DarkBlue>(</FONT>enc<FONT color=DarkBlue>)</FONT>
{
final = <FONT color=Blue>new byte</FONT>[OutputBlockSize];
}
<FONT color=Blue>else</FONT>
{
<FONT color=Blue>if</FONT> <FONT color=DarkBlue>(</FONT>inputCount <FONT color=DarkBlue>==</FONT> <FONT color=Red>0</FONT><FONT color=DarkBlue>)</FONT>
{
final = <FONT color=Blue>new byte</FONT>[<FONT color=Red>0</FONT>];
}
<FONT color=Blue>else</FONT>
{
<FONT color=Blue>if</FONT> <FONT color=DarkBlue>(</FONT>PaddingValue <FONT color=DarkBlue>==</FONT> PaddingMode<FONT color=DarkBlue>.</FONT>Zeros<FONT color=DarkBlue>)</FONT>
{
<FONT color=Blue>for</FONT> <FONT color=DarkBlue>(</FONT><FONT color=Blue>int</FONT> i = outputBuffer<FONT color=DarkBlue>.</FONT>Length - <FONT color=Red>1</FONT>; i <FONT color=DarkBlue>>=</FONT> <FONT color=Red>0</FONT>; i<FONT color=DarkBlue>--)</FONT>
{
<FONT color=Blue>if</FONT> <FONT color=DarkBlue>(</FONT>outputBuffer[i] <FONT color=DarkBlue>!=</FONT> <FONT color=Red>0</FONT><FONT color=DarkBlue>)</FONT>
{
final = <FONT color=Blue>new byte</FONT>[i + <FONT color=Red>1</FONT>];
<FONT color=Blue>break</FONT>;
}
}
}
<FONT color=Blue>else</FONT>
{
<FONT color=Blue>byte</FONT> pk = outputBuffer[outputBuffer<FONT color=DarkBlue>.</FONT>Length - <FONT color=Red>1</FONT>];
<FONT color=Blue>for</FONT> <FONT color=DarkBlue>(</FONT><FONT color=Blue>int</FONT> i = outputBuffer<FONT color=DarkBlue>.</FONT>Length - <FONT color=Red>1</FONT>; <FONT color=DarkBlue>(</FONT>i <FONT color=DarkBlue>>=</FONT> outputBuffer<FONT color=DarkBlue>.</FONT>Length - <FONT color=Red>1</FONT> - pk<FONT color=DarkBlue>)</FONT>; i<FONT color=DarkBlue>--)</FONT>
{
<FONT color=Blue>if</FONT> <FONT color=DarkBlue>(</FONT>outputBuffer[i] <FONT color=DarkBlue>!=</FONT> pk<FONT color=DarkBlue>)</FONT>
{
final = <FONT color=Blue>new byte</FONT>[i + <FONT color=Red>1</FONT>];
<FONT color=Blue>break</FONT>;
}
}
}
}
}
}
<FONT color=Blue>if</FONT> <FONT color=DarkBlue>(</FONT>final <FONT color=DarkBlue>==</FONT> <FONT color=Blue>null</FONT><FONT color=DarkBlue>)</FONT>
{
final = <FONT color=Blue>new byte</FONT>[outputBuffer<FONT color=DarkBlue>.</FONT>Length];
}
Buffer<FONT color=DarkBlue>.</FONT>BlockCopy<FONT color=DarkBlue>(</FONT>outputBuffer, inputOffset, final, <FONT color=Red>0</FONT>, final<FONT color=DarkBlue>.</FONT>Length<FONT color=DarkBlue>)</FONT>;
IVValue = initial_iv;
<FONT color=Blue>return</FONT> final;
}
<FONT color=Blue>public sealed override</FONT> ICryptoTransform CreateDecryptor<FONT color=DarkBlue>(</FONT><FONT color=Blue>byte</FONT><FONT color=DarkBlue>[]</FONT> rgbKey, <FONT color=Blue>byte</FONT><FONT color=DarkBlue>[]</FONT> rgbIV<FONT color=DarkBlue>)</FONT>
{
<FONT color=Blue>if</FONT> <FONT color=DarkBlue>(</FONT>rgbKey <FONT color=DarkBlue>!=</FONT> <FONT color=Blue>null</FONT><FONT color=DarkBlue>)</FONT>
{
Key = rgbKey;
}
<FONT color=Blue>if</FONT> <FONT color=DarkBlue>(</FONT>rgbIV <FONT color=DarkBlue>!=</FONT> <FONT color=Blue>null</FONT><FONT color=DarkBlue>)</FONT>
{
IV = rgbIV;
}
curmode = TransformMode<FONT color=DarkBlue>.</FONT>Decrypt;
<FONT color=Blue>return this</FONT>;
}
<FONT color=Blue>public sealed override</FONT> ICryptoTransform CreateEncryptor<FONT color=DarkBlue>(</FONT><FONT color=Blue>byte</FONT><FONT color=DarkBlue>[]</FONT> rgbKey, <FONT color=Blue>byte</FONT><FONT color=DarkBlue>[]</FONT> rgbIV<FONT color=DarkBlue>)</FONT>
{
<FONT color=Blue>if</FONT> <FONT color=DarkBlue>(</FONT>rgbKey <FONT color=DarkBlue>!=</FONT> <FONT color=Blue>null</FONT><FONT color=DarkBlue>)</FONT>
{
Key = rgbKey;
}
<FONT color=Blue>if</FONT> <FONT color=DarkBlue>(</FONT>rgbIV <FONT color=DarkBlue>!=</FONT> <FONT color=Blue>null</FONT><FONT color=DarkBlue>)</FONT>
{
IV = rgbIV;
}
curmode = TransformMode<FONT color=DarkBlue>.</FONT>Encrypt;
<FONT color=Blue>return this</FONT>;
}
<FONT color=Blue>public sealed override void</FONT> GenerateIV<FONT color=DarkBlue>()</FONT>
{
IVValue = <FONT color=Blue>new byte</FONT>[BlockSizeValue/<FONT color=Red>8</FONT>];
<FONT color=Blue>byte</FONT><FONT color=DarkBlue>[]</FONT> h = HASH<FONT color=DarkBlue>.</FONT>ComputeHash<FONT color=DarkBlue>(</FONT>Key<FONT color=DarkBlue>)</FONT>;
Buffer<FONT color=DarkBlue>.</FONT>BlockCopy<FONT color=DarkBlue>(</FONT>h,<FONT color=Red>0</FONT>,IVValue,<FONT color=Red>0</FONT>, IVValue<FONT color=DarkBlue>.</FONT>Length<FONT color=DarkBlue>)</FONT>;
}
<FONT color=Blue>public sealed override void</FONT> GenerateKey<FONT color=DarkBlue>()</FONT>
{
KeyValue = <FONT color=Blue>new byte</FONT>[KeySizeValue/<FONT color=Red>8</FONT>];
RANDOM<FONT color=DarkBlue>.</FONT>GetNonZeroBytes<FONT color=DarkBlue>(</FONT>KeyValue<FONT color=DarkBlue>)</FONT>;
}
<FONT color=Blue>public override byte</FONT><FONT color=DarkBlue>[]</FONT> IV
{
<FONT color=Blue>get</FONT>
{
<FONT color=Blue>return base</FONT><FONT color=DarkBlue>.</FONT>IV;
}
<FONT color=Blue>set</FONT>
{
<FONT color=Blue>base</FONT><FONT color=DarkBlue>.</FONT>IV = <FONT color=Blue>value</FONT>;
initial_iv = IVValue<FONT color=DarkBlue>.</FONT>Clone<FONT color=DarkBlue>()</FONT> <FONT color=Blue>as byte</FONT><FONT color=DarkBlue>[]</FONT>;
}
}
<FONT color=Blue>public virtual bool</FONT> CanReuseTransform
{
<FONT color=Blue>get</FONT> {<FONT color=Blue>return false</FONT>;}
}
<FONT color=Blue>public virtual bool</FONT> CanTransformMultipleBlocks
{
<FONT color=Blue>get</FONT> { <FONT color=Blue>return false</FONT>; }
}
<FONT color=Blue>static string</FONT> ByteAsString<FONT color=DarkBlue>(</FONT><FONT color=Blue>byte</FONT><FONT color=DarkBlue>[]</FONT> input<FONT color=DarkBlue>)</FONT>
{
<FONT color=Blue>string</FONT> output = <FONT color=Maroon>""</FONT>;
<FONT color=Blue>if</FONT> <FONT color=DarkBlue>(</FONT>input <FONT color=DarkBlue>!=</FONT> <FONT color=Blue>null</FONT><FONT color=DarkBlue>)</FONT>
{
<FONT color=Blue>foreach</FONT> <FONT color=DarkBlue>(</FONT><FONT color=Blue>byte</FONT> b <FONT color=Blue>in</FONT> input<FONT color=DarkBlue>)</FONT>
{
output <FONT color=DarkBlue>+=</FONT> b<FONT color=DarkBlue>.</FONT>ToString<FONT color=DarkBlue>(</FONT><FONT color=Maroon>"X2"</FONT><FONT color=DarkBlue>)</FONT>;
}
}
<FONT color=Blue>else</FONT>
{
output = <FONT color=Maroon>"NULL"</FONT>;
}
<FONT color=Blue>return</FONT> output;
}
<FONT color=Blue>public sealed override string</FONT> ToString<FONT color=DarkBlue>()</FONT>
{
<FONT color=Blue>if</FONT> <FONT color=DarkBlue>(</FONT>Debugger<FONT color=DarkBlue>.</FONT>IsAttached<FONT color=DarkBlue>)</FONT>
{
<FONT color=Blue>return string</FONT><FONT color=DarkBlue>.</FONT>Format<FONT color=DarkBlue>(</FONT><FONT color=Maroon>"{0}(KEY({3}) = {1},\nIV({4}) = {2})"</FONT>, GetType<FONT color=DarkBlue>().</FONT>Name,
ByteAsString<FONT color=DarkBlue>(</FONT>KeyValue<FONT color=DarkBlue>)</FONT>, ByteAsString<FONT color=DarkBlue>(</FONT>IVValue<FONT color=DarkBlue>)</FONT>, KeySize, BlockSize<FONT color=DarkBlue>)</FONT>;
}
<FONT color=Blue>else</FONT>
{
<FONT color=Blue>return base</FONT><FONT color=DarkBlue>.</FONT>ToString<FONT color=DarkBlue>()</FONT>;
}
}
}
|
|
|
|
|
Well done leppie, nice class.
If he had difficulty with the docs hes gonna have hours of fun with that;)
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
Hi,
I've read your thread. I agree that sometimes it's frustrating not to get the answers you'ld like, but if Cpians don't know the answer, they can't give it to you.
Regarding your question. If I understood correctly you want to write your own encryption tool?
Encryption is actually nothing more then mathematics. If you can find out how the mathematics is applied in encryption you would be able to encrypt/decrypt files/strings/...
I have written (a very, very) simple encryption tool for strings a while back. I don't know if it can help you. (if you think it would, I can send it to you)
My suggestion would be that you look up the mathematics you need and start from there.
Good luck with your problem!
Coulda, woulda, shoulda doesn't matter if you don't.
<marquee>
|
|
|
|
|
I already built my encryption mathematics\algorythem all I need is the info on the parameters of the ICryptoTransform interface members implements.
you just didn't understand what is going on here.
|
|
|
|
|
NaNg15241 wrote: and I will keep posting it every time it crosses the next page untill I will have answers, and as you see.... this is REALY ORGENT!
This sounds like you are trying to hold us to ransom, and doing this is likely to get you ignored!
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
but there is a fact that there are more then 8 msgs that is not mine in this thread. :P
|
|
|
|
|
I said likely, not definately!
Listen, Ive taken a look at all your threads that you've posted here, and you seem like a polite enough kid who's just eager to learn...which is a good start. However, bully tactics like "ill post this every day until it gets answered" will end up annoying people.
Let me give you some advice, start by reading the thread stuck to the top titled "How to get answers to your questions". Note that it says that for coding questions you should post the relevant code you are using. Nobody can help you with a coding question without it.
That said, you are asking about a very specific corner of the framework that not everyone deals with. Even in a community as large as CP there will be few people that really know this well. What this means is that if YOU want to learn this corner of the framework you'll have to spend days, and maybe even weeks reading, trying and understanding the crypto classes. Nobody can hand you this knowledge within one simple post.
Good luck, and your enthusiasm for answering other people's questions has not gone unnoticed I promise!
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|