public bool CheckPublicKey( [Argument(description: "Public key.")] string key, [Argument(description: "Testing string.", defaultValue: "LEA4")] string str ) { try { key = key.Replace("-", null); return(LEA4.CheckPublicKey(Encoding.Default.GetBytes(str), new Key(false, new byte[2, 2] { { Convert.ToByte(key.Substring(0, 2), 16), Convert.ToByte(key.Substring(2, 2), 16) }, { Convert.ToByte(key.Substring(4, 2), 16), Convert.ToByte(key.Substring(6, 2), 16) }, }, 4))); } catch (Exception ex) { Logger.Log(Logger.Level.Error, "Could not generate a public key."); Logger.Log(ex); } return(false); }
public string GetPrivateKey( [Argument(description: "Private key.")] string key ) { try { key = key.Replace("-", null); return(LEA4.GetPrivateKey(new Key( false, new byte[2, 2] { { Convert.ToByte(key.Substring(0, 2), 16), Convert.ToByte(key.Substring(2, 2), 16) }, { Convert.ToByte(key.Substring(4, 2), 16), Convert.ToByte(key.Substring(6, 2), 16) }, }, 4)).ToString()); } catch (Exception ex) { Logger.Log(Logger.Level.Error, "Could not convert the given public key into a private key."); Logger.Log(ex); } return(null); }
public string GeneratePublicKey( [Argument(description: "Generate a reversible key.", defaultValue: true)] bool reversible, [Argument(description: "Display in hexadecimal.", defaultValue: true)] bool hexa ) { try { Key k = LEA4.GeneratePublicKey(); return(hexa ? k.ToHexadecimal() : k.ToDecimal()); } catch (Exception ex) { Logger.Log(Logger.Level.Error, "Could not generate a public key."); Logger.Log(ex); } return(null); }