Explore Courses Blog Tutorials Interview Questions
0 votes
in Blockchain by (12.7k points)
edited by

To apply in a blockchain application, I needed to generate random 64-digit hexadecimal numbers in R.

I thought that due to the capacity of computers, obtaining such a 64-digit hexadecimal number at once is rather cumbersome, perhaps impossible.

So, I thought that I should produce random hexadecimal numbers with rather low digits, and bring (concatenate) them together to obtain a random 64-digit hexadecimal number.

I am near solution:

library(fBasics) * 1e6)))

produces random hexadecimal numbers. The problem is that in some of the instances, I get a 6-digit hexadecimal number, in some instances, I get a 7-digit hexadecimal number. Hence, fixing this became a priority first.

Any idea?

1 Answer

0 votes
by (29.5k points)
edited by

A simple way to go about is by sampling each digit and paste them together.

paste0(sample(c(0:9, LETTERS[1:6]), 64, T), collapse = '')
## [1] "4C6EF08E87F7A91E305FEBAFAB8942FEBC07C353266522374D07C1832CE5A164"

Know the blockchain better through Blockchain Certification by Intellipaat.

Browse Categories