// Check AES decription public void TestAESdecryption() { String originalData = "8031b6fb67ee4cf45e5bff5e6927f016675ed9c8e89b5aed8f9418c8ca04b65706c71a65039302e937342eed892be761251bb3596b64145060fd478a2fe839c7"; String expectedResult = "Super long test that should be encrypted properly"; byte[] DataToBeDecoded = HexEncDec.StringToByteArray(originalData); byte[] byteResult = EncryptionHelper.decryptWithAes(DataToBeDecoded, aesKey); String result = Encoding.UTF8.GetString(byteResult); Assert.IsTrue(String.Equals(expectedResult, result, StringComparison.InvariantCulture)); }
// **** Code to be reviewed - it compiles, but he has little if any relationship with the Dart code... // **** public String getEncoded() { byte[] seedBytes = HexEncDec.StringToByteArray(Seed); Ed25519KeyPairGenerator wkGen = new Ed25519KeyPairGenerator(); SecureRandom rnd = new SecureRandom(seedBytes); Ed25519KeyGenerationParameters genPar = new Ed25519KeyGenerationParameters(rnd); wkGen.Init(genPar); AsymmetricCipherKeyPair keys = wkGen.GenerateKeyPair(); Ed25519PublicKeyParameters key = (Ed25519PublicKeyParameters)keys.Public; byte[] output = key.GetEncoded(); return(Convert.ToBase64String(output)); }
public void TestParsingKeys() { String RSAPublicText = TestResources.RSAPublicText; // Test the parsing RsaKeyParameters pubKey = RSAKeyParser.parsePublicKeyFromPem(RSAPublicText); // Here to make debug simpler... BigInteger modulus = pubKey.Modulus; BigInteger exp = pubKey.Exponent; BigInteger testModulus = new BigInteger(HexEncDec.StringToByteArray(TestResources.EncodedHexPubModulus)); BigInteger testExp = new BigInteger(TestResources.PubExponentTextValue.ToString()); // Check the RSA Assert.IsTrue(modulus.CompareTo(testModulus) == 0); Assert.IsTrue(exp.CompareTo(testExp) == 0); }