示例#1
0
    public byte[] VerifiedEncrypt(byte[] clearData, byte[] recvPublicKey, byte[] sendPrivateKey)
    {
        var nonce     = Sodium.PublicKeyBox.GenerateNonce();
        var cryptData = Sodium.PublicKeyBox.Create(clearData, nonce, sendPrivateKey, recvPublicKey);
        var total     = new NonceAndCrypt
        {
            Nonce = nonce,
            Crypt = cryptData,
        };

        return(KpMsgPack.Ser(total));
    }
示例#2
0
    public byte[] Encrypt(byte[] clearData, byte[] key)
    {
        var nonce = Sodium.SecretBox.GenerateNonce();
        var crypt = Sodium.SecretBox.Create(clearData, nonce, key);
        var total = new NonceAndCrypt
        {
            Nonce = nonce,
            Crypt = crypt,
        };

        return(KpMsgPack.Ser(total));
    }