<p>As stated by RedGrittyBlock this is really more of a web development question vs a bitcoin one. Also although it can be fun to create keys from file sources, typically it's a bad idea and should be more of a learning exercise than for actual use. To that end you should look at the built-in <a href="https://developer.mozilla.org/en-US/docs/Web/API/FileReader" rel="nofollow noreferrer">FileReader() API</a> if you are seeking a simple javascript solution.</p>
<p>For example if you were doing a drag-drop to capture the file</p>
<pre><code>holder.ondrop = function(event) {
  event.preventDefault();

  var file = event.dataTransfer.files[0];
  var reader = new FileReader();

  reader.onload = function(event) { 
    var binary = event.target.result;
    
    //Do whatever you want with the data, sha256 hash it, etc
    
    //var mnemonic = bip39.entropyToMnemonic(binary);
   
  };

  reader.readAsBinaryString(file);
};
</code></pre>
<p><a href="https://github.com/coinables/coinables.github.io/blob/master/dragdrop/index.html" rel="nofollow noreferrer">Source</a></p>

CC BY-SA 4.0
2022-04-22T17:17:46.320Z
I'm sorry, but can you explain it to me in more detail?


holder.ondrop = function(event) {
^
ReferenceError: holder is not defined
jepekoh
CC BY-SA 4.0
2022-04-22T16:51:26.333Z
2022-04-22T16:51:26.333Z
m1xolyd1an
<p>how to make an entropy to mnemonic converter
to read a file with an array line by line
in python or javascript
there</p>
<p>var bip39 = require('bip39')</p>
<p>var mnemonic = bip39.entropyToMnemonic('00000000000000000000000000000000')
console.log(mnemonic)</p>
<p>but I can't figure out how to read from the file
if there is a python easier tell me</p>

CC BY-SA 4.0
2022-04-22T13:24:44.440Z
stackoverflow.com must already have excellent answers covering [reading a file line by line](https://stackoverflow.com/q/3277503/477035) in either Python or Javascript.
RedGrittyBrick
CC BY-SA 4.0
2022-04-22T13:34:05.507Z
I know what it is, I don’t understand how to add
jepekoh
CC BY-SA 4.0
2022-04-24T01:51:48.813Z
This is more a python programming question, not about BTC so much.
HansBKK
<python><mnemonic-seed>
entropy to mnemonic converter
jepekoh
# entropy to mnemonic converter

(Asked by: username_0 on 2022-04-22)

how to make an entropy to mnemonic converter
to read a file with an array line by line
in python or javascript
there

var bip39 = require('bip39')

var mnemonic = bip39.entropyToMnemonic('00000000000000000000000000000000')
console.log(mnemonic)

but I can't figure out how to read from the file
if there is a python easier tell me

**Tags:** python, mnemonic-seed

> **Comments:**
> **username_1**: stackoverflow.com must already have excellent answers covering [reading a file line by line](https://stackoverflow.com/q/3277503/477035) in either Python or Javascript.  
> **username_0**: I know what it is, I don’t understand how to add  
> **username_2**: This is more a python programming question, not about BTC so much.  

---

## 1 answers

### Answer by username_3 on 2022-04-22. Score: 0

As stated by RedGrittyBlock this is really more of a web development question vs a bitcoin one. Also although it can be fun to create keys from file sources, typically it's a bad idea and should be more of a learning exercise than for actual use. To that end you should look at the built-in FileReader() API if you are seeking a simple javascript solution.
For example if you were doing a drag-drop to capture the file
holder.ondrop = function(event) {
  event.preventDefault();

  var file = event.dataTransfer.files[0];
  var reader = new FileReader();

  reader.onload = function(event) { 
    var binary = event.target.result;
    
    //Do whatever you want with the data, sha256 hash it, etc
    
    //var mnemonic = bip39.entropyToMnemonic(binary);
   
  };

  reader.readAsBinaryString(file);
};

Source

> **Comments:**
> **username_0**: I'm sorry, but can you explain it to me in more detail?   holder.ondrop = function(event) { ^ ReferenceError: holder is not defined  

---

