Search the Community
Showing results for tags 'endian'.
-
How to easily swap or change endianness in Javascript, NodeJS, etc. with one simple function! changeEndianness() const changeEndianness = (string) => { const result = []; let len = string.length - 2; while (len >= 0) { result.push(string.substr(len, 2)); len -= 2; } return result.join(''); } You can then use this function with any string to convert its endianness Example of using function: var yourstringvar = 'Your string goes here to swap endianness'; var newendian = changeEndianness(yourstringvar); console.log('Your newly swapped endian string', newendian);
-
- 1
-
- javascript
- change
- (and 15 more)
-
So not a lot of information out there, but if you want to convert a Bitcoin or Denarius or any standard crypto typically, you take the block hex to a block hash (typically used for block explorers and things) you just do the following: changeEndianness(SHA256(SHA256(BLOCKHEX))) So basically visually in text it would be: BLOCKHEX => Hashed to SHA256 => Hashed to SHA256 => Swap Endianness = Block Hash You are just hashing the hex twice and then swapping the endianness to obtain the hash of the block.