Exemplo n.º 1
0
        public Compressed Compress(Cleartext cleartext)
        {
            Guard.NotNull(cleartext);

            byte[] compressed = Deflate.Compress(cleartext.Text, Encoding.UTF8);

            return(new Compressed(compressed));
        }
Exemplo n.º 2
0
        // same in ChatWorker
        string DecryptBytesToText(byte[] cipherBytes, KeyMaterial64 keyMaterial64)
        {
            var decodeResponse = this.ixdsCryptoService.BinaryDecodeXDSSec(cipherBytes, null);

            if (!decodeResponse.IsSuccess)
            {
                throw new Exception(decodeResponse.Error);
            }
            var decrpytResponse = this.ixdsCryptoService.Decrypt(decodeResponse.Result, keyMaterial64, null);

            if (!decrpytResponse.IsSuccess)
            {
                throw new Exception(decrpytResponse.Error);
            }
            Cleartext cleartext = decrpytResponse.Result;

            return(cleartext.Text);
        }
Exemplo n.º 3
0
        public Response <Cleartext> Decrypt(CipherV2 cipherV2, KeyMaterial64 keyMaterial64, LongRunningOperationContext context)
        {
            var response = new Response <Cleartext>();

            try
            {
                Compressed compressed = DecryptCommon(cipherV2, keyMaterial64, context);

                Cleartext cleartext = this._internal.Decompress(compressed);

                response.Result = cleartext;
                response.SetSuccess();
            }
            catch (Exception e)
            {
                response.SetError(e);
            }
            return(response);
        }
Exemplo n.º 4
0
        public Response <CipherV2> Encrypt(Cleartext cleartext, KeyMaterial64 keyMaterial64, RoundsExponent roundsExponent,
                                           LongRunningOperationContext context)
        {
            var response = new Response <CipherV2>();

            try
            {
                Guard.NotNull(new object[] { cleartext, keyMaterial64, roundsExponent });
                EnsurePlatform();

                Compressed compressed = this._internal.Compress(cleartext);

                var cipherV2 = EncryptCommon(keyMaterial64, roundsExponent, context, compressed);

                response.Result = cipherV2;
                response.SetSuccess();
            }
            catch (Exception e)
            {
                response.SetError(e);
            }
            return(response);
        }