Security->encrypt() HTML friendly

Hey All,

I was wondering how I can make the output of


security->encrypt($data,0,$security->generateRandomKey(),'') 



Html friendly.

Basically I would like to stick it into a hidden form input. Placing it in a url::to works but all the methods I have attempted urlencode() etc don’t spit out the right content.

Does Yii2 have a function to do this?

Thanks

Wrap it in base64_encode() and then use base64_decode() on the other end.

generateRandomString() ?

base64 is the way.

Thank you all!