Created
February 28, 2023 21:11
-
-
Save saitgulmez/7e30ec3721faa5a1a5f954124bfc3ecd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var blake = require('blakejs') | |
| const main = async () => { | |
| const hex_value = "0a0b"; | |
| console.log(hex_value) | |
| // Output: 0a0b | |
| const buffer = Buffer.from(hex_value, 'hex') | |
| console.log(buffer) | |
| // Output: <Buffer 0a 0b> | |
| const generated_array = Uint8Array.from(buffer); | |
| console.log("generated_array = ", generated_array) | |
| // Output: Uint8Array(2) [10, 11] | |
| const hash_array = blake.blake2b(generated_array, null, 32); | |
| console.log("hash_array = ",hash_array) | |
| /* | |
| Output: [142, 59, 186, 133, 108, 58, 127, 230, | |
| 208, 88, 83, 109, 200, 64, 136, 45, | |
| 71, 67, 115, 236, 132, 46, 69, 255, | |
| 202, 241, 7, 147, 132, 254, 117, 233] | |
| */ | |
| const backToHexString = Buffer.from(hash_array).toString('hex'); | |
| console.log("backToHexString = ",backToHexString) | |
| // Following is the output that I want to get by using the same input | |
| // in ruby blake2b hash algorithms but couldn't find a proper library for that | |
| // Output: 8e3bba856c3a7fe6d058536dc840882d474373ec842e45ffcaf1079384fe75e9 | |
| }; | |
| main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment