Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 26, 2023. It is now read-only.

refactor(crypto): hex #421

Merged
merged 1 commit into from Nov 9, 2021
Merged

refactor(crypto): hex #421

merged 1 commit into from Nov 9, 2021

Conversation

ghost
Copy link

@ghost ghost commented Nov 3, 2021

Description

This PR converts a buffer to a hex string in a simpler way.

const b = require('crypto').randomBytes(16)
console.log(b)
// <Buffer 06 6e d5 0e 66 b2 9b 6e a6 b2 0b 21 ff de a7 17>

const hexStr = b.toString('hex')
console.log(hexStr)
// 066ed50e66b29b6ea6b20b21ffdea717

https://nodejs.org/api/buffer.html

The Buffer class is a subclass of JavaScript's Uint8Array class and extends it with methods that cover additional use cases. Node.js APIs accept plain Uint8Arrays wherever Buffers are supported as well.

Motivation and Context

How has this been tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • Add tests to cover changes as needed.
  • Update documentation as needed.

@ghost ghost requested review from bb111189, renlulu and teye as code owners November 3, 2021 07:26
@codecov-commenter
Copy link

codecov-commenter commented Nov 3, 2021

Codecov Report

Merging #421 (2c916d2) into dev (06e4527) will decrease coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #421      +/-   ##
==========================================
- Coverage   82.16%   82.12%   -0.04%     
==========================================
  Files          43       43              
  Lines        1811     1807       -4     
  Branches      332      332              
==========================================
- Hits         1488     1484       -4     
  Misses        322      322              
  Partials        1        1              
Impacted Files Coverage Δ
packages/zilliqa-js-crypto/src/random.ts 94.73% <100.00%> (-0.92%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 06e4527...2c916d2. Read the comment docs.

@bb111189 bb111189 merged commit c8e5caa into Zilliqa:dev Nov 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants