Encrypt password in groovy

Asked

Viewed 107 times

1

I am developing an application that will have a login screen that will be based on data (user, password) already saved in a database Mysql, and so I thought I would apply the same Hash which was first used to encrypt the user’s password to validate whether the user who is trying to access the application is already registered in the bank. It’s the first time I do something related to password encryption, so while searching for the subject I found that and that content related to encrypting the password in JAVA, but every time I try to test the codes indicated in links this part of the code already has an error in the script in Groovy:

MessageDigest algorithm = MessageDigest.getInstance("MD5");
byte messageDigest[] = algorithm.digest("senha".getBytes("UTF-8")); \\O erro é na palavra byte mostra um erro

Error displayed:

Groovy:Primitive type literal: byte cannot be used as a method name at line: 22 column: 1. File:C:\BonitaBPMCommunity-7.3.3\workspace\default\src-providedGroovy\acript1494448116792.groovy @ line 22, column 1.

If you have a hint of how I can encrypt a string type variable via script Groovy.

1 answer

0

You have two options

byte[] messageDigest = ...

Or

def messageDigest = ...

It’s long since posting, but for future reference.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.