Print a string in a cryptic manner, the string is invisible in the code

时间:2015-10-30 23:42:31

标签: ruby

How can I print a secret string "Secret foo string" using ruby code, without actually having the string in the code itself? So when someone runs the code, it will print out the string but be a surprise. Preferably in one line of code, like in a return statement. Thanks :)

1 个答案:

答案 0 :(得分:2)

I mean, you could base64 encode the string first, and then return the decoded version: require "base64" /* ... */ return Base64.decode64("U2VjcmV0IGZvbyBzdHJpbmc=")