मैं एक नया विंडोज 8 डेवलपर हूं, मेरे पास कुछ कोड है जो लिनक्स के लिए डिज़ाइन किया गया था लेकिन जीटीके # स्थापित होने तक विंडोज़ पर भी चलाया गया था।सिस्टम.Security.Cryptography बनाम Windows.Security.Cryptography
मैं वर्तमान में विंडोज 8 को एक आधुनिक यूआई (मेट्रो) ऐप के रूप में उस एप्लिकेशन को पोर्ट कर रहा हूं। यह अच्छी तरह से चल रहा है, सिवाय इसके कि, जब मैं अपना मुख्य व्युत्पन्न कोड आयात करता हूं (जो उपयोगकर्ता का पासवर्ड लेता है और इससे 256 बिट कुंजी प्राप्त करता है), विजुअल स्टूडियो अल्टीमेट 2013 इंगित करता है कि यह using System.Security.Cryptography
को नहीं पहचानता है।
विंडोज 8 डेवलपर वेबसाइट देखने के बाद, मैंने पाया कि एक नई कक्षा, Windows.Security.Cryptography
उपलब्ध है, हालांकि, यह विजुअल स्टूडियो द्वारा भी पहचाना नहीं जा रहा है। Windows 8 में
- System.Security.Cryptography उपलब्ध है:
तो, अब आप आधार है, इसलिए मैं कुछ प्रश्न हैं? यदि हां, तो आरटी संस्करण समर्थित है? मैं विजुअल स्टूडियो को कैसे पहचान सकता हूं?
- Windows.System.Security अलग कैसे है, और क्या Rfc2898DeriveBytes के लिए एक संगत वर्ग/विधि है? संगत रूप से, मेरा मतलब है कि एक ही पासवर्ड दिया गया है और नमक परिणाम के समान कुंजी प्राप्त करने का एक तरीका है।
मुझे क्या करना चाहते हैं के रूप में स्पष्टीकरण के लिए, मेरी कुंजी व्युत्पत्ति कोड के नीचे पोस्ट किया जाता है:
public class GetKey
{
// constructor
public GetKey (bool use=true, string password="none")
{ if (use == true)
{
this.genSalt();
byte[] salt = this.salt;
Rfc2898DeriveBytes pwdKey = new Rfc2898DeriveBytes(password, salt, 4000);
this.key = pwdKey.GetBytes(32);
this.iv = pwdKey.GetBytes(16);
}
}
// properties
private byte[] key;
private byte[] iv;
private byte[] salt;
// methods
public void retrieveKey(string password)
{
try
{
byte[] salt = this.salt;
Rfc2898DeriveBytes pwdKey = new Rfc2898DeriveBytes(password, salt, 4000);
this.key = pwdKey.GetBytes(32);
this.iv = pwdKey.GetBytes(16);
}
catch (Exception e)
{
GenericDialog win = new GenericDialog("Unknown Error: " + e.Message, "Error Notice", "Unknown Error");
win.Show();
}
}
public void genSalt()
{
string sSalt = UtilityClass.randString(16);
byte[] salt = UtilityClass.ToByteArray(sSalt);
this.salt = salt;
}
public byte[] returnKey()
{
return this.key;
}
public byte[] returnIv()
{
return this.iv;
}
public byte[] returnSalt()
{
return this.salt;
}
public bool setSalt(string salt)
{
try
{
this.salt = Convert.FromBase64String(salt);
}
catch
{
GenericDialog win = new GenericDialog("Decryption failed because the salt was invalid.", "Error Notice", "Invalid Salt");
win.Show();
return false;
}
return true;
}
}
'Windows.Security.Cryptography' केवल तीन वर्गों या मुझे लगता है के बाद ऐसा है, नहीं है कि तुम क्या कर रहे हैं शामिल करने के लिए लगता है। मुझे कोई कारण नहीं दिख रहा कि क्यों 'System.Security.Cryptography' विंडोज 8 का हिस्सा नहीं होना चाहिए। यह .NET ढांचे में है, तो क्यों नहीं होगा? मुझे लगता है कि आप एक लापता संदर्भ मुद्दे से पीड़ित हैं। –
क्या कुछ वर्गों के लिए मैन्युअल रूप से संदर्भों को जोड़ा जाना चाहिए? – Razick
हां, आपको सिस्टम.क्योरिटी और फिर सिस्टम का संदर्भ जोड़ना होगा। सुरक्षा। क्रिप्टोग्राफी हल हो जाएगी लेकिन विंडोज 8 डेस्कटॉप ऐप्स के लिए केवल विंडोज स्टोर (नी मेट्रो) नहीं है। –