private void KeyBtnLoad_Click(object sender, EventArgs e) { string b64PubKey = keyPublicInput.Text; string b64PriKey = keyPrivateInput.Text; if (string.IsNullOrEmpty(b64PubKey)) { LoadImg = _xlRibbon.LoadImage("error") as Bitmap; ErrorText = "Missing pulic key"; return; } if (string.IsNullOrEmpty(b64PriKey)) { LoadImg = _xlRibbon.LoadImage("error") as Bitmap; ErrorText = "Missing private key"; return; } try { var key = ECDsaHelper.Import(b64PubKey.FromBase64String(), b64PriKey.FromBase64String()); SecretariumFunctions.Scp.Set(key); LoadImg = _xlRibbon.LoadImage("success") as Bitmap; ErrorText = " "; } catch (Exception) { try { var key = ECDsaHelper.Import(b64PubKey.FromBase64String().ReverseEndianness(), b64PriKey.FromBase64String().ReverseEndianness()); SecretariumFunctions.Scp.Set(key); LoadImg = _xlRibbon.LoadImage("success") as Bitmap; ErrorText = " "; } catch (Exception) { LoadImg = _xlRibbon.LoadImage("error") as Bitmap; ErrorText = "Unable to load keys"; } } }