Exemplo n.º 1
0
    public void TestStringCypherWithoutSalt()
    {
        IStringCypherService service = new StringCypherService();
        var cyphertext = service.Encrypt(_plaintext, _password);
        var decrypted  = service.Decrypt(cyphertext, _password);

        Assert.AreEqual(_plaintext, decrypted);

        _ = service.Decrypt(cyphertext, _badPassword);
    }
Exemplo n.º 2
0
    public void TestStringCypherWithSalt()
    {
        IStringCypherService service = new StringCypherService();
        ISalter salter     = new Salter();
        var     salt       = salter.GenerateSalt(64);
        var     cyphertext = service.Encrypt(_plaintext, _password, salt);
        var     decrypted  = service.Decrypt(cyphertext, _password, salt);

        Assert.AreEqual(_plaintext, decrypted);

        salt = salter.GenerateSalt(64);
        _    = service.Decrypt(cyphertext, _password, salt);
    }