/// <summary> /// Hash computes the hash of whole backend keyspace, /// including key, lease, and other buckets in storage in async. /// This is designed for testing ONLY! /// Do not rely on this in production with ongoing transactions, /// since Hash operation does not hold MVCC locks. /// Use "HashKV" API instead for "key" bucket consistency checks. /// </summary> /// <param name="request">Hash Request</param> /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param> /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param> /// <param name="cancellationToken">An optional token for canceling the call.</param> /// <returns>Hash Response</returns> public async Task <HashResponse> HashAsync(HashRequest request, Grpc.Core.Metadata headers = null, DateTime?deadline = null, CancellationToken cancellationToken = default) { return(await CallEtcdAsync(async (connection) => await connection._maintenanceClient .HashAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false)); }
/// <summary> /// Hash computes the hash of whole backend keyspace, /// including key, lease, and other buckets in storage in async. /// This is designed for testing ONLY! /// Do not rely on this in production with ongoing transactions, /// since Hash operation does not hold MVCC locks. /// Use "HashKV" API instead for "key" bucket consistency checks. /// </summary> /// <param name="request">Hash Request</param> /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param> /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param> /// <param name="cancellationToken">An optional token for canceling the call.</param> /// <returns>Hash Response</returns> public async Task <HashResponse> HashAsync(HashRequest request, Grpc.Core.Metadata headers = null, DateTime?deadline = null, CancellationToken cancellationToken = default) { HashResponse response = new HashResponse(); bool success = false; int retryCount = 0; while (!success) { try { response = await _balancer.GetConnection().maintenanceClient .HashAsync(request, headers, deadline, cancellationToken); success = true; } catch (RpcException ex) when(ex.StatusCode == StatusCode.Unavailable) { retryCount++; if (retryCount >= _balancer._numNodes) { throw; } } } return(response); }
/// <summary> /// Hash computes the hash of whole backend keyspace, /// including key, lease, and other buckets in storage in async. /// This is designed for testing ONLY! /// Do not rely on this in production with ongoing transactions, /// since Hash operation does not hold MVCC locks. /// Use "HashKV" API instead for "key" bucket consistency checks. /// </summary> /// <param name="request">Hash Request</param> /// <returns>Hash Response</returns> public async Task <HashResponse> HashAsync(HashRequest request, Metadata headers = null) { HashResponse response = new HashResponse(); bool success = false; int retryCount = 0; while (!success) { try { response = await _balancer.GetConnection().maintenanceClient.HashAsync(request, headers); success = true; } catch (RpcException ex) when(ex.StatusCode == StatusCode.Unavailable) { retryCount++; if (retryCount >= _balancer._numNodes) { throw ex; } } } return(response); }
public async Task <IActionResult> Post([FromBody] HashRequest hashRequest) { //var txId = await certService.DeployContract(hash); //return Json(txId); certService.BulkDeployContractWithBackgroundTask(hashRequest.OrganizationId, hashRequest.Hash); return(Ok()); }
/// <summary> /// Hash computes the hash of whole backend keyspace, /// including key, lease, and other buckets in storage in async. /// This is designed for testing ONLY! /// Do not rely on this in production with ongoing transactions, /// since Hash operation does not hold MVCC locks. /// Use "HashKV" API instead for "key" bucket consistency checks. /// </summary> /// <param name="request">Hash Request</param> /// <returns>Hash Response</returns> public async Task <HashResponse> HashAsync(HashRequest request, Metadata headers = null) { HashResponse response = new HashResponse(); response = await _balancer.GetConnection().maintenanceClient.HashAsync(request, headers); return(response); }
public override Task <HashResponse> CreateHash(HashRequest hashRequest, ServerCallContext context) { var hash = this.passwordStorage.CreateHash(hashRequest.Password); return(Task.FromResult(new HashResponse { Hash = hash })); }
public HashResponse GenerateHash(HashRequest hashRequest) { var hashedMessage = GetSha256Hash(hashRequest.Message); return(new HashResponse { Digest = hashedMessage }); }
/// <summary> /// Hash computes the hash of whole backend keyspace, /// including key, lease, and other buckets in storage. /// This is designed for testing ONLY! /// Do not rely on this in production with ongoing transactions, /// since Hash operation does not hold MVCC locks. /// Use "HashKV" API instead for "key" bucket consistency checks. /// </summary> /// <param name="request">Hash Request</param> /// <returns>Hash Response</returns> public HashResponse Hash(HashRequest request, Metadata headers = null) { HashResponse response = new HashResponse(); response = _balancer.GetConnection().maintenanceClient.Hash(request, headers); return(response); }
public override Task <HashResponse> GetHash(HashRequest request, ServerCallContext context) { _logger.LogDebug("Getting hash for {request}", request); var hashResponse = new HashResponse { Hash = GetSha256Hash(request.Input) }; _logger.LogDebug("Hash generated for {request} is {response}", request, hashResponse); return(Task.FromResult(hashResponse)); }
public IHttpActionResult Post([FromBody] HashRequest hashRequest) { IHasher hasher = new HashFactory().Instantiate(hashRequest.Operation, hashRequest.Info.Key); byte[] stringToHash = CalculateStringToHash(hashRequest); byte[] hash = hasher.Hash(stringToHash); HashResponse hashResponse = new HashResponse { Hex = BitConverter.ToString(hash).Replace("-", ""), Base64 = Convert.ToBase64String(hash), Timestamp = DateTime.Now.ToString() }; return(Ok(hashResponse)); }
public string Compute(string algorithm, byte[] bytes) { if (client != null) { var request = new HashRequest { Algorithm = algorithm, Bytes = ByteString.CopyFrom(bytes) }; var response = client.Compute(request); return(response.Hash); } else { throw new System.Exception("Client has not been started"); } }
private byte[] CalculateStringToHash(HashRequest hashRequest) { string salt = hashRequest.Info.Salt; byte[] pepper = new byte[1]; string pepperString = null; if (hashRequest.Info.Pepper) { using (var rng = new RNGCryptoServiceProvider()) { rng.GetBytes(pepper); pepperString = Encoding.UTF8.GetString(pepper); } } byte[] buffer = Encoding.UTF8.GetBytes(salt + hashRequest.ClearText.Text + pepperString); return(buffer); }
/// <summary> /// Hash computes the hash of whole backend keyspace, /// including key, lease, and other buckets in storage. /// This is designed for testing ONLY! /// Do not rely on this in production with ongoing transactions, /// since Hash operation does not hold MVCC locks. /// Use "HashKV" API instead for "key" bucket consistency checks. /// </summary> /// <param name="request">Hash Request</param> /// <returns>Hash Response</returns> public HashResponse Hash(HashRequest request) { HashResponse response = new HashResponse(); try { response = _maintenanceClient.Hash(request); } catch (RpcException) { ResetConnection(); throw; } catch { throw; } return(response); }
/// <summary> /// Hash computes the hash of whole backend keyspace, /// including key, lease, and other buckets in storage in async. /// This is designed for testing ONLY! /// Do not rely on this in production with ongoing transactions, /// since Hash operation does not hold MVCC locks. /// Use "HashKV" API instead for "key" bucket consistency checks. /// </summary> /// <param name="request">Hash Request</param> /// <returns>Hash Response</returns> public async Task <HashResponse> HashAsync(HashRequest request) { HashResponse response = new HashResponse(); try { response = await _maintenanceClient.HashAsync(request); } catch (RpcException) { ResetConnection(); throw; } catch { throw; } return(response); }
public IActionResult Post([FromBody] HashRequest hashRequest) { return(Ok(hasher.GenerateHash(hashRequest))); }
/// <summary> /// Hash computes the hash of whole backend keyspace, /// including key, lease, and other buckets in storage. /// This is designed for testing ONLY! /// Do not rely on this in production with ongoing transactions, /// since Hash operation does not hold MVCC locks. /// Use "HashKV" API instead for "key" bucket consistency checks. /// </summary> /// <param name="request">Hash Request</param> /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param> /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param> /// <param name="cancellationToken">An optional token for canceling the call.</param> /// <returns>Hash Response</returns> public HashResponse Hash(HashRequest request, Grpc.Core.Metadata headers = null, DateTime?deadline = null, CancellationToken cancellationToken = default) => CallEtcd((connection) => connection._maintenanceClient .Hash(request, headers, deadline, cancellationToken));
public IActionResult Post([FromBody] HashRequest hashRequest) { var hashResponse = _cryptographer.GenerateHash(hashRequest); return(Ok(hashResponse)); }
public async Task <IActionResult> SalvarPlano([FromBody] HashRequest hash) { var empresas = clienteServico.SalvarPlano(hash.Email, hash.Valor, hash.Plano, hash.Nome, hash.Funcionarios); return(await Response(empresas, clienteServico.Notificacoes)); }