public Compressed Compress(Cleartext cleartext) { Guard.NotNull(cleartext); byte[] compressed = Deflate.Compress(cleartext.Text, Encoding.UTF8); return(new Compressed(compressed)); }
// 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); }
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); }
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); }