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