public void AesGcmEncryptionMatches(string plainText, string key) { var encrypted = CryptographyHelper.EncryptData(SymmetricAlgorithms.AESGCM, Encoding.UTF8.GetBytes(plainText), Encoding.UTF8.GetBytes(key)); var decrypted = CryptographyHelper.DecryptData(SymmetricAlgorithms.AESGCM, encrypted, Encoding.UTF8.GetBytes(key)); Assert.Equal(Encoding.UTF8.GetString(decrypted), plainText); }
public void SymmetricAlgorithmsEncryptionMatches(SymmetricAlgorithms enumValue) { string toProcess = "`~1234567890-=qwertyuiop[]\\ASDFGHJKL:\"ZXCVBNM<>?ăîșțâ"; string key = "{>@#F09\0"; EncryptText symmetricAlgorithm = new EncryptText { Algorithm = enumValue, Encoding = new InArgument <Encoding>(ExpressionServices.Convert((env) => System.Text.Encoding.Unicode)) }; Dictionary <string, object> arguments = new Dictionary <string, object>(); arguments.Add(nameof(EncryptText.Input), toProcess); arguments.Add(nameof(EncryptText.Key), key); WorkflowInvoker invoker = new WorkflowInvoker(symmetricAlgorithm); string activityString = (string)invoker.Invoke(arguments)[nameof(symmetricAlgorithm.Result)]; byte[] algorithmBytes = CryptographyHelper.DecryptData(enumValue, Convert.FromBase64String(activityString), Encoding.Unicode.GetBytes(key)); Assert.Equal(toProcess, Encoding.Unicode.GetString(algorithmBytes)); }