Skip to content

Commit 3c65f82

Browse files
committed
added some hex2 utils.
1 parent 6b37bb9 commit 3c65f82

File tree

8 files changed

+68
-6
lines changed

8 files changed

+68
-6
lines changed

cmd/factorize/input.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
12530420637925486546091071420646625511213697460882658601625809411059296885116455382174430850063426791962363532300038259317487858539930757373877634464857792960032611966200444163444561060413062212826059376730168231579547650790018826095033685314676234147812546153417141264398147319434833264784733696993540685486638087109649077700678375787569028989008520584942393883993261884471584796151979925527521709229562222660251336905936320708010780977117895515244078417703171732592294935847772955258949627677445494998843361681887606789751360772221930793397038853770220948576247660016130173661900338090855459653882684474977065117766
2+
17151819699050597377131531854839376360822957416204566351363466278974488061081727404253537449339023437281155761565979324574844137150555246884376722949799076697435957177040628018470243115480662733084710631500303985011820629620577217149307423838288030197229073897983461894035386357276132084141889153617542622080857175678556274577290128951832260788403793779395423572369054740464177240717550652284716507113876640743090170770576145707120614375936414645553743344470160738508887720577947721152831974328208106864615825053113744541880216034837433203118067399993546445706503981301629791762005008570149368752396164628240896526066
3+
24125981290986017942579389861904075699780053634877019733132335118082299311415286800346335243978006326215960075324471559120355336842324858895575059421721972339663776414368270649786781213868274306732638329961827497629194907934594301759662239225156330176378675589937606502479314620646802782645571546461511894367980161636679697431898749511563463914681817281004947485248121601208324326817580748069475923571954601405159663874261583012507752222780535332824475552489557067506547116865688259510481453458882194170346314933896463120699714743885180999746546400969122482762450333177401443700368256880401453572602822607150628613037
4+
25740609338713740451383832219479235754725863832971871709639871951325368281319992368451262957380136738580984102498156209504885107559888573720240447527237806133642436469516970239275070052173257754870411104735371884755523202600179398871425366502515715266452605364235557174019275304673914171201727814904867065260172618151017445653576240689799042052044569671613376665582868028630135782974492411027594574902599011691959663456535899855511102361695299659576814952621611895134991478842870083290035465895237115347496968533727080716248257574675641700193666651376471835648150223199064934366333949097859326375867152574830306704720

cmd/factorize/testf.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
#!/bin/bash
22

3-
# Compile the factorize program
4-
go build
5-
63
# Define the input file
7-
input_file="../intgen/intgen_output.txt"
4+
input_file="./input.txt"
85

96
# Define the output file
107
output_file="factorize_output.txt"
@@ -22,5 +19,6 @@ fi
2219

2320
# Read each line from the input file and factorize the number
2421
while IFS= read -r number; do
22+
echo "$number"
2523
./factorize "$number" >> "$output_file"
2624
done < "$input_file"

cmd/hex2int/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module hex2int
2+
3+
go 1.24

cmd/hex2int/main.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package main
2+
3+
import (
4+
"bufio"
5+
"fmt"
6+
"math/big"
7+
"os"
8+
"strings"
9+
)
10+
11+
func main() {
12+
// Prompt the user for a hex value
13+
fmt.Print("Enter a hexadecimal value: ")
14+
reader := bufio.NewReader(os.Stdin)
15+
hexInput, err := reader.ReadString('\n')
16+
if err != nil {
17+
fmt.Println("Error reading input:", err)
18+
return
19+
}
20+
21+
// Trim whitespace and newlines from the input
22+
hexInput = strings.TrimSpace(hexInput)
23+
24+
// Convert hex string to big integer
25+
bigIntValue := new(big.Int)
26+
_, success := bigIntValue.SetString(hexInput, 16)
27+
if !success {
28+
fmt.Println("Error: Invalid hexadecimal value")
29+
return
30+
}
31+
32+
// Output to console
33+
fmt.Println("Decimal value:", bigIntValue.String())
34+
35+
// Write to output.txt file
36+
file, err := os.Create("output.txt")
37+
if err != nil {
38+
fmt.Println("Error creating output file:", err)
39+
return
40+
}
41+
defer func(file *os.File) {
42+
closeError := file.Close()
43+
if closeError != nil {
44+
fmt.Println("Error closing output file:", closeError)
45+
}
46+
}(file)
47+
48+
_, err = file.WriteString(bigIntValue.String())
49+
if err != nil {
50+
fmt.Println("Error writing to output file:", err)
51+
return
52+
}
53+
54+
fmt.Println("Result successfully written to output.txt")
55+
}

cmd/runecalc/FyneApp.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
Name = "runecalc"
44
ID = "com.cmbsolver.runecalc"
55
Version = "1.0.0"
6-
Build = 37
6+
Build = 39

cmd/runecalc2/FyneApp.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
Name = "runecalc2"
44
ID = "com.cmbsolver.runecalctwo"
55
Version = "1.0.0"
6-
Build = 16
6+
Build = 18

go.work

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,5 @@ use (
5151
cmd/wordlecheat
5252
cmd/hex2bytearray
5353
cmd/permute
54+
cmd/hex2int
5455
)

manifest.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ gemproduct
1818
gemsum
1919
genseq
2020
hex2bytearray
21+
hex2int
2122
intgen
2223
ipaddressgen
2324
isprime

0 commit comments

Comments
 (0)