public void EncryptWithIosPublicKey() { var km = new KeyMaster(); var c = new Cryptographer(km); const string KeyString = "MIIBCgKCAQEAr3a1JDZOo6oo6HGEhmFmkwmV6UNPdB4ZTZnv5KHI2j9Cc90h9aZvRkzd28NSh0fPP" + "/RxRMzAb5r08QgqcHWK5reBQGcj3k+f1gTyUlDssIBlbbP2Z/7VJsHPXoU53MLUZ4K/BPEKYkZV" + "CsWmVB07sWV4ThTsX934pxT+ybNH8FDdjGfLFwU3fINXQHVf34iwYcSJPWbtPb6dSrXD8c0h/X/" + "3WCaMjLhyvuXi4jdBLGAAP/UXBobqwFDcrW1CO5RSyEIjKcR2A6fvN1Kx6zGLzaZjWdb5miBU73" + "b6C0vjVjlIarK/+EYBrVUDLl3yBPfJn29SOoyQeejY8pTQ9XzgAwIDAQAB"; PublicKey publicKey = km.DecodePublicKey(KeyString); Message msg = c.HybridEncrypt("test", publicKey); Assert.IsNotNull(msg); Assert.IsNotNull(msg.Key); Assert.IsNotNull(msg.Data); Log.Info("Key : " + msg.Key); Log.Info("Data : " + msg.Data); }
public void HybridEncryptDecrypt() { var km = new KeyMaster(); var c = new Cryptographer(km); KeyPair kp = km.GenerateKeyPair(); var msg = c.HybridEncrypt("test", kp.PublicKey); Assert.IsNotNull(msg); Assert.IsNotNull(msg.Data); Assert.IsNotNull(msg.Key); var test = c.HybridDecrypt(msg, kp.PrivateKey); Assert.IsNotNull(test); Assert.AreEqual("test", test); }