c# ECDiffieHellmanCng WPF Visual Studio












-2















One week ago i started making an crypto app with window interface (wpf). Mainly my code is based on this one: ECC code and i stucked at last step i guess.
Here is the part of my code:



public class Me
{
public static byte MyPublicKey;

public static void Main2()
{
MainWindow windoww = new MainWindow();
string message = System.IO.File.ReadAllText(@"C:Users32ketrabsourcereposWpfApp4message.txt");

using (ECDiffieHellmanCng ecd = new ECDiffieHellmanCng())
{
ecd.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash;
ecd.HashAlgorithm = CngAlgorithm.Sha256;
MyPublicKey = ecd.PublicKey.ToByteArray();

if (windoww.ComboBox1.Text == "User 1")
{
User1 user1 = new User1();
User2 user2 = new User2();
CngKey k = CngKey.Import(user1.User1PublicKey, CngKeyBlobFormat.EccPublicBlob);
byte MyKey = ecd.DeriveKeyMaterial(CngKey.Import(user1.User1PublicKey, CngKeyBlobFormat.EccPublicBlob));
Send(MyKey, message, out byte encryptedMessage, out byte iv);

if (windoww.ComboBoxLoad.Text == "User 1")
user1.Receive(encryptedMessage, iv);
if (windoww.ComboBoxLoad.Text == "User 2")
user2.Receive(encryptedMessage, iv);
}
if (windoww.ComboBox1.Text == "User 2")
{
User1 user1 = new User1();
User2 user2 = new User2();
CngKey k = CngKey.Import(user2.User2PublicKey, CngKeyBlobFormat.EccPublicBlob);
byte MyKey = ecd.DeriveKeyMaterial(CngKey.Import(user2.User2PublicKey, CngKeyBlobFormat.EccPublicBlob));
Send(MyKey, message, out byte encryptedMessage, out byte iv);

if (windoww.ComboBoxLoad.Text == "User 1")
user1.Receive(encryptedMessage, iv);
if (windoww.ComboBoxLoad.Text == "User 2")
user2.Receive(encryptedMessage, iv);
}
}
}


At this point i have two ComboBoxes (ComboBox1 and ComboBoxLoad). I wanted to encrypt file with ComboBox1.Text user and decrypt with ComboBoxLoad.Text user to simulate stealing data, but it doesnt matter which value of ComboBox i pick cuz everytime i encrypt and decrypt file correctly.



Thanks for any help :)










share|improve this question























  • What is a "cuz"?

    – Uwe Keim
    Jan 19 at 15:53











  • i wanted to write "because"

    – Bartek Poreba
    Jan 19 at 15:56











  • If you want reasonable answers, try writing high-quality, reasonable, well spell-checked question.

    – Uwe Keim
    Jan 19 at 16:17
















-2















One week ago i started making an crypto app with window interface (wpf). Mainly my code is based on this one: ECC code and i stucked at last step i guess.
Here is the part of my code:



public class Me
{
public static byte MyPublicKey;

public static void Main2()
{
MainWindow windoww = new MainWindow();
string message = System.IO.File.ReadAllText(@"C:Users32ketrabsourcereposWpfApp4message.txt");

using (ECDiffieHellmanCng ecd = new ECDiffieHellmanCng())
{
ecd.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash;
ecd.HashAlgorithm = CngAlgorithm.Sha256;
MyPublicKey = ecd.PublicKey.ToByteArray();

if (windoww.ComboBox1.Text == "User 1")
{
User1 user1 = new User1();
User2 user2 = new User2();
CngKey k = CngKey.Import(user1.User1PublicKey, CngKeyBlobFormat.EccPublicBlob);
byte MyKey = ecd.DeriveKeyMaterial(CngKey.Import(user1.User1PublicKey, CngKeyBlobFormat.EccPublicBlob));
Send(MyKey, message, out byte encryptedMessage, out byte iv);

if (windoww.ComboBoxLoad.Text == "User 1")
user1.Receive(encryptedMessage, iv);
if (windoww.ComboBoxLoad.Text == "User 2")
user2.Receive(encryptedMessage, iv);
}
if (windoww.ComboBox1.Text == "User 2")
{
User1 user1 = new User1();
User2 user2 = new User2();
CngKey k = CngKey.Import(user2.User2PublicKey, CngKeyBlobFormat.EccPublicBlob);
byte MyKey = ecd.DeriveKeyMaterial(CngKey.Import(user2.User2PublicKey, CngKeyBlobFormat.EccPublicBlob));
Send(MyKey, message, out byte encryptedMessage, out byte iv);

if (windoww.ComboBoxLoad.Text == "User 1")
user1.Receive(encryptedMessage, iv);
if (windoww.ComboBoxLoad.Text == "User 2")
user2.Receive(encryptedMessage, iv);
}
}
}


At this point i have two ComboBoxes (ComboBox1 and ComboBoxLoad). I wanted to encrypt file with ComboBox1.Text user and decrypt with ComboBoxLoad.Text user to simulate stealing data, but it doesnt matter which value of ComboBox i pick cuz everytime i encrypt and decrypt file correctly.



Thanks for any help :)










share|improve this question























  • What is a "cuz"?

    – Uwe Keim
    Jan 19 at 15:53











  • i wanted to write "because"

    – Bartek Poreba
    Jan 19 at 15:56











  • If you want reasonable answers, try writing high-quality, reasonable, well spell-checked question.

    – Uwe Keim
    Jan 19 at 16:17














-2












-2








-2








One week ago i started making an crypto app with window interface (wpf). Mainly my code is based on this one: ECC code and i stucked at last step i guess.
Here is the part of my code:



public class Me
{
public static byte MyPublicKey;

public static void Main2()
{
MainWindow windoww = new MainWindow();
string message = System.IO.File.ReadAllText(@"C:Users32ketrabsourcereposWpfApp4message.txt");

using (ECDiffieHellmanCng ecd = new ECDiffieHellmanCng())
{
ecd.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash;
ecd.HashAlgorithm = CngAlgorithm.Sha256;
MyPublicKey = ecd.PublicKey.ToByteArray();

if (windoww.ComboBox1.Text == "User 1")
{
User1 user1 = new User1();
User2 user2 = new User2();
CngKey k = CngKey.Import(user1.User1PublicKey, CngKeyBlobFormat.EccPublicBlob);
byte MyKey = ecd.DeriveKeyMaterial(CngKey.Import(user1.User1PublicKey, CngKeyBlobFormat.EccPublicBlob));
Send(MyKey, message, out byte encryptedMessage, out byte iv);

if (windoww.ComboBoxLoad.Text == "User 1")
user1.Receive(encryptedMessage, iv);
if (windoww.ComboBoxLoad.Text == "User 2")
user2.Receive(encryptedMessage, iv);
}
if (windoww.ComboBox1.Text == "User 2")
{
User1 user1 = new User1();
User2 user2 = new User2();
CngKey k = CngKey.Import(user2.User2PublicKey, CngKeyBlobFormat.EccPublicBlob);
byte MyKey = ecd.DeriveKeyMaterial(CngKey.Import(user2.User2PublicKey, CngKeyBlobFormat.EccPublicBlob));
Send(MyKey, message, out byte encryptedMessage, out byte iv);

if (windoww.ComboBoxLoad.Text == "User 1")
user1.Receive(encryptedMessage, iv);
if (windoww.ComboBoxLoad.Text == "User 2")
user2.Receive(encryptedMessage, iv);
}
}
}


At this point i have two ComboBoxes (ComboBox1 and ComboBoxLoad). I wanted to encrypt file with ComboBox1.Text user and decrypt with ComboBoxLoad.Text user to simulate stealing data, but it doesnt matter which value of ComboBox i pick cuz everytime i encrypt and decrypt file correctly.



Thanks for any help :)










share|improve this question














One week ago i started making an crypto app with window interface (wpf). Mainly my code is based on this one: ECC code and i stucked at last step i guess.
Here is the part of my code:



public class Me
{
public static byte MyPublicKey;

public static void Main2()
{
MainWindow windoww = new MainWindow();
string message = System.IO.File.ReadAllText(@"C:Users32ketrabsourcereposWpfApp4message.txt");

using (ECDiffieHellmanCng ecd = new ECDiffieHellmanCng())
{
ecd.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash;
ecd.HashAlgorithm = CngAlgorithm.Sha256;
MyPublicKey = ecd.PublicKey.ToByteArray();

if (windoww.ComboBox1.Text == "User 1")
{
User1 user1 = new User1();
User2 user2 = new User2();
CngKey k = CngKey.Import(user1.User1PublicKey, CngKeyBlobFormat.EccPublicBlob);
byte MyKey = ecd.DeriveKeyMaterial(CngKey.Import(user1.User1PublicKey, CngKeyBlobFormat.EccPublicBlob));
Send(MyKey, message, out byte encryptedMessage, out byte iv);

if (windoww.ComboBoxLoad.Text == "User 1")
user1.Receive(encryptedMessage, iv);
if (windoww.ComboBoxLoad.Text == "User 2")
user2.Receive(encryptedMessage, iv);
}
if (windoww.ComboBox1.Text == "User 2")
{
User1 user1 = new User1();
User2 user2 = new User2();
CngKey k = CngKey.Import(user2.User2PublicKey, CngKeyBlobFormat.EccPublicBlob);
byte MyKey = ecd.DeriveKeyMaterial(CngKey.Import(user2.User2PublicKey, CngKeyBlobFormat.EccPublicBlob));
Send(MyKey, message, out byte encryptedMessage, out byte iv);

if (windoww.ComboBoxLoad.Text == "User 1")
user1.Receive(encryptedMessage, iv);
if (windoww.ComboBoxLoad.Text == "User 2")
user2.Receive(encryptedMessage, iv);
}
}
}


At this point i have two ComboBoxes (ComboBox1 and ComboBoxLoad). I wanted to encrypt file with ComboBox1.Text user and decrypt with ComboBoxLoad.Text user to simulate stealing data, but it doesnt matter which value of ComboBox i pick cuz everytime i encrypt and decrypt file correctly.



Thanks for any help :)







c# wpf visual-studio xaml cryptography






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 19 at 15:49









Bartek PorebaBartek Poreba

1




1













  • What is a "cuz"?

    – Uwe Keim
    Jan 19 at 15:53











  • i wanted to write "because"

    – Bartek Poreba
    Jan 19 at 15:56











  • If you want reasonable answers, try writing high-quality, reasonable, well spell-checked question.

    – Uwe Keim
    Jan 19 at 16:17



















  • What is a "cuz"?

    – Uwe Keim
    Jan 19 at 15:53











  • i wanted to write "because"

    – Bartek Poreba
    Jan 19 at 15:56











  • If you want reasonable answers, try writing high-quality, reasonable, well spell-checked question.

    – Uwe Keim
    Jan 19 at 16:17

















What is a "cuz"?

– Uwe Keim
Jan 19 at 15:53





What is a "cuz"?

– Uwe Keim
Jan 19 at 15:53













i wanted to write "because"

– Bartek Poreba
Jan 19 at 15:56





i wanted to write "because"

– Bartek Poreba
Jan 19 at 15:56













If you want reasonable answers, try writing high-quality, reasonable, well spell-checked question.

– Uwe Keim
Jan 19 at 16:17





If you want reasonable answers, try writing high-quality, reasonable, well spell-checked question.

– Uwe Keim
Jan 19 at 16:17












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54268789%2fc-sharp-ecdiffiehellmancng-wpf-visual-studio%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54268789%2fc-sharp-ecdiffiehellmancng-wpf-visual-studio%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Callistus III

Plistias Cous

Index Sanctorum