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"
|
|
|
|
)
|
|
|
|
|
|
|
|
// 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())
|
2020-04-28 13:37:42 +00:00
|
|
|
h := hash.Sha256(msg).BytesBE()
|
2020-08-07 11:37:49 +00:00
|
|
|
ic.VM.Estack().PushVal(h)
|
2020-04-28 13:37:42 +00:00
|
|
|
return nil
|
|
|
|
}
|
2020-07-22 09:22:20 +00:00
|
|
|
|
|
|
|
// 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())
|
2020-07-22 09:22:20 +00:00
|
|
|
h := hash.RipeMD160(msg).BytesBE()
|
2020-08-07 11:37:49 +00:00
|
|
|
ic.VM.Estack().PushVal(h)
|
2020-07-22 09:22:20 +00:00
|
|
|
return nil
|
|
|
|
}
|