hash := fmt.Sprintf("%s", sha256.Sum256([]byte("hello"))
이렇게 하면 hash가 string이잖아?
그래서 아래처럼 출력해봤는데 터미널에서 인코딩 이상하게 되던데
터미널 문제임?
fmt.Printf("%s", hash)
,�M�_��&�;*�\�B^s3b���$
이렇게 깨져서나옴
hash := fmt.Sprintf("%s", sha256.Sum256([]byte("hello"))
이렇게 하면 hash가 string이잖아?
그래서 아래처럼 출력해봤는데 터미널에서 인코딩 이상하게 되던데
터미널 문제임?
fmt.Printf("%s", hash)
,�M�_��&�;*�\�B^s3b���$
이렇게 깨져서나옴
https://pkg.go.dev/crypto/sha256#Sum256
여기 예제처럼 string이 아니라 %x로 처리가능
나도 이거저거하다가 %x하니까 되긴됬는데 왜 저게 안되나 궁금해서
아 생각해보니까 %x로하고 그 결과값을 string으로 바꾸는거니까 저게맞네 ;
처음 sprint때 타입만 스트링으로 바꾸고 인코딩은 전혀 손 안 댐