]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blobdiff - src/js/index.js
Entropy is left-padded to 256 bits
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / src / js / index.js
index 531880084d71139bb3aeae33177a16c3f32f9d1b..c3c0a4aae4da5bddedde6543a668659a8516139a 100644 (file)
             var hash = sjcl.hash.sha256.hash(entropy.cleanStr);
             var hex = sjcl.codec.hex.fromBits(hash);
             bits = BigInteger.parse(hex, 16).toString(2);
-            for (var i=0; i<256-bits.length; i++) {
+            while (bits.length % 256 != 0) {
                 bits = "0" + bits;
             }
             // Truncate hash to suit number of words