Instead of getPlainText(), try hudson.util.Secret.toString(secret)

If that doesn't work, then try printing both the encrypted value and
the plain text from the `secret` object in the encrypt method... if it
gives the result you expect, then yes, there seems to be an issue with
state. It might not be picking the right crypto algorithm if you're
doing this across different JVMs, for example.

Sean

On Mon, Oct 31, 2016 at 9:39 AM, Mohan Radhakrishnan
<[email protected]> wrote:
> Hi,
>        I have a doubt here. This code encrypts but doesn't decrypt. Instead
> I get the encrypted string back from the decrypt function. Does it need
> state to be maintained between these two functions ?
>
> Thanks,
> Mohan
>
> def encrypt(server ):
>     value = server.run_script("""
>     secret = hudson.util.Secret.fromString("Password")
>     println secret.getEncryptedValue()
>     """)
>     print (value)
>
> def decrypt(server ):
>     decryptedvalue = server.run_script("""
>     secret =
> hudson.util.Secret.fromString("zPc9cFNDcj8RuRIKigYfsTQMiuCrv1lO+Y5qqJXc6RQ=")
>     println secret.getPlainText()
>     """)
>     return decryptedvalue
>
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/0afdb0c5-9365-40d5-8e28-7a106dbcca78%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAPAActe3Hbu0udfTpyL4hs5j--Q0W2rV9tTB_Zz%3Dg3RfnO%3DZyw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to