Do you want have string “1” for 1 or wide of string should be some specific wide?
full one line to hash in sha256 and same continues…
means example:- 000000000000000000000000000000000000000000000000000000000000077a
gives 02C62AE7237817928D659F1004A920030FAE9556A6B6FEBF6701B60AD5285961
as sha256
Did you got any result? waiting for correct code.
Code below works for me, you just should know about print-specifiers (%x, %d, %s ,…)
package main
import (
"crypto/sha256"
"fmt"
"math/big"
"strings"
)
func main() {
// Print header
fmt.Printf("%64s %64s\n", "Raw-sha256", "hash-256")
// Initialise big numbers with small numbers
count, one := big.NewInt(0), big.NewInt(1)
// Loop forever because we're never going to hit the end anyway
for i := 0; i < 100; i++ {
// Increment our counter
count.Add(count, one)
str := count.String()
str = strings.Repeat("0", 64-len(str)) + str
sha256 := sha256.Sum256([]byte(str))
// Print keys
fmt.Printf("%s %X\n", str, sha256)
}
}
Code is Nice But But my Charactars are missing abcdef0123456789 and it only has numbers.
Ah, sorry, I just forgot that your task still to variate “abcdef0123456789” string. Fixed:
package main
import (
"crypto/sha256"
"fmt"
"math/big"
)
func main() {
// Print header
fmt.Printf("%64s %64s\n", "Raw-sha256", "hash-256")
// Initialise big numbers with small numbers
count, one := big.NewInt(0), big.NewInt(1)
// Create a slice to pad our count to 32 bytes
padded := make([]byte, 32)
// Loop forever because we're never going to hit the end anyway
for i := 0; i < 100; i++ {
// Increment our counter
count.Add(count, one)
// Copy count value's bytes to padded slice
copy(padded[32-len(count.Bytes()):], count.Bytes())
sha256 := sha256.Sum256([]byte(fmt.Sprintf("%X", padded)))
// Print keys
fmt.Printf("%X %X\n", padded, sha256)
}
}
So I only add convertion to hex here:
fmt.Sprintf(“%X”, padded)
because you must hash exactly the string which display after in hex.
This is the Extract Code. For this Solution. Great Work
, Grey Shatter and I learned alot. now i merge this code with another code in github and will look, if it fits in or not.