neoneo-go/pkg/core/interop/crypto/hash.go

23 lines
556 B
Go
Raw Normal View History

package crypto
import (
"github.com/nspcc-dev/neo-go/pkg/core/interop"
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
)
// Sha256 returns sha256 hash of the data.
2020-08-07 11:37:49 +00:00
func Sha256(ic *interop.Context) error {
msg := getMessage(ic, ic.VM.Estack().Pop().Item())
h := hash.Sha256(msg).BytesBE()
2020-08-07 11:37:49 +00:00
ic.VM.Estack().PushVal(h)
return nil
}
// RipeMD160 returns RipeMD160 hash of the data.
2020-08-07 11:37:49 +00:00
func RipeMD160(ic *interop.Context) error {
msg := getMessage(ic, ic.VM.Estack().Pop().Item())
h := hash.RipeMD160(msg).BytesBE()
2020-08-07 11:37:49 +00:00
ic.VM.Estack().PushVal(h)
return nil
}