Skip to content

Hex2Bin error #33

@zhoupufelix

Description

@zhoupufelix

package main

import (
"fmt"
"strconv"
)

// Hex2bin hex2bin()
func Hex2bin(data string) (string, error) {
i, err := strconv.ParseInt(data, 16, 0)
if err != nil {
return "", err
}
return strconv.FormatInt(i, 2), nil
}

func main(){
fmt.Println(Hex2bin("48656c6c6f20576f726c6421"))
}

When I used this method, it returned an error below.
//strconv.ParseInt: parsing "48656c6c6f20576f726c6421": value out of range

If I use php function hex2bin()

:

It shows us ,

Hello World!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions