13 lines
166 B
Go
13 lines
166 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"crypto/sha256"
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
|
func CalcId(str string, len int) string {
|
||
|
id := sha256.Sum256([]byte(str))
|
||
|
|
||
|
return fmt.Sprintf("%X", id)[0:len]
|
||
|
}
|