public ExportPublicKey ( ) : Windows.Storage.Streams.IBuffer | ||
return | Windows.Storage.Streams.IBuffer |
private void AsymmetricImportExport(CryptographicKey keyPair) { String algName = AlgorithmNames.SelectionBoxItem.ToString(); AsymmetricKeyAlgorithmProvider Algorithm = AsymmetricKeyAlgorithmProvider.OpenAlgorithm(algName); // Export the public key. IBuffer blobOfPublicKey = keyPair.ExportPublicKey(); IBuffer blobOfKeyPair = keyPair.Export(); SignVerifyText.Text += " Key pair was successfully exported.\n"; // Import the public key. CryptographicKey keyPublic = Algorithm.ImportPublicKey(blobOfPublicKey); // Check the key size. if (keyPublic.KeySize != keyPair.KeySize) { SignVerifyText.Text += "ImportPublicKey failed! The imported key's size did not match the original's!"; return; } SignVerifyText.Text += " Public key was successfully imported.\n"; // Import the key pair. keyPair = Algorithm.ImportKeyPair(blobOfKeyPair); // Check the key size. if (keyPublic.KeySize != keyPair.KeySize) { SignVerifyText.Text += "ImportKeyPair failed! The imported key's size did not match the original's!"; return; } SignVerifyText.Text += " Key pair was successfully imported.\n"; }
public void InitializeUniqueIdKeyPair(string keypair) { timestampKey = asym.ImportKeyPair(Convert.FromBase64String(keypair).AsBuffer()); UniqueId = Convert.ToBase64String(timestampKey.ExportPublicKey(CryptographicPublicKeyBlobType.Capi1PublicKey).ToArray()); }