我目前正在使用RSA加密来加密敏感数据的应用程序中工作。我曾尝试合并标准加密方法,但它引发了错误。有人能告诉我我是否做对了吗?
下面是我用来加密值的代码(string2Encrypt)
import javax.crypto.Cipher
import java.security.KeyFactory
import java.security.spec.X509EncodedKeySpec
def publicKey = '5dy47yt7ty5ad283c0c4955f53csa24wse244wfrfafa34239rsgd89gfsg8342r93r98efae89fdf9983r9gjsdgnsgjkwt23r923r2r0943tf9sdg9d8gfsgf90sgsf89grw098tg09s90ig90g90s903r5244r517823rea8f8werf9842tf24tf42e0132saf9fg6f65afa43f12r103tf4040ryrw0e9rtqtwe0r9t04ty8842t03e9asfads0fgadg675'
def x509PublicKey = new X509EncodedKeySpec(publicKey.decodeBase64())
def keyFactory = KeyFactory.getInstance('RSA')
defFactory.generatePublicc(x509PublicKey)
def string2Encrypt = '("testinga@gmail.com|testingb@gmail.com").'
def encryptCipher = Cipher.getInstance('RSA')encryptCipher.init(Cipher.ENCRYPT_MODE key)
def secretMessage = string2Encrypt.getBytes('UTF-8')
def encryptedMessage = encryptCipher.doFinal(secretMessage)
def encodedMessage = encryptedMessage.encodedBase64().toString()
vars.put('encodedMessage',encodedMessage)
我遇到的错误
javax.script.scriptException: groovy.lang.MissingPropertException: No Such Property: `defFactory for class: Script21`
传递的参数加密后,我希望看到的输出
"ParameterEmailDetails":"428f8wefg87hg8s74tr52493r5219r0921tf09gv09sg0958t347tr1348r8feqacadvf98bnvncsaopdpwoq8r3r234r89r024rtf90eopfgsodg9503y68yhhi898jngdhhs9hg538hfhlhko539gh35l35s09fhbs09ns9htwj986jh3509h3250bsf90hsf9nsf0h9sf9h0"
请在这方面给予帮助。
1条答案
按热度按时间8cdiaqws1#
您在尝试从某个源代码复制粘贴代码时出错,显示的不是有效的Groovy代码,因此解释/编译失败
这一行:
应该看起来像
还有这一行:
应分为2行:
或在语句之间放置分号:
更多信息: