Skip to content
This repository has been archived by the owner on Jun 21, 2020. It is now read-only.

CaledoniaProject/bccrypto-csharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deprecated

See https://www.nuget.org/packages/PInvoke.BCrypt/ for details.

Example

private static string _decryptWithKey(byte[] message, byte[] key)
{
    const int MAC_BIT_SIZE   = 128;
    const int NONCE_BIT_SIZE = 96;

    using (var cipherStream = new MemoryStream(message))
    using (var cipherReader = new BinaryReader(cipherStream))
    {
        var nonce      = cipherReader.ReadBytes(NONCE_BIT_SIZE / 8);
        var cipher     = new GcmBlockCipher(new AesEngine());
        var parameters = new AeadParameters(new KeyParameter(key), MAC_BIT_SIZE, nonce);
        cipher.Init(false, parameters);

        var cipherText = cipherReader.ReadBytes(message.Length);
        var plainText  = new byte[cipher.GetOutputSize(cipherText.Length)];

        var len = cipher.ProcessBytes(cipherText, 0, cipherText.Length, plainText, 0);
        cipher.DoFinal(plainText, len);

        return Encoding.UTF8.GetString(plainText);
    }
}

About

Bouncy crypto with AES-256-GCM only

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages