Simple Encryption in Ruby without external gems

前端 未结 9 942
庸人自扰
庸人自扰 2020-12-08 07:43

I need a simple encryption for some text strings. I want to create coupon codes and make them look cool so subsequently created code should look very different. (And besides

9条回答
  •  佛祖请我去吃肉
    2020-12-08 08:30

    I can recommend you uuencode and uudecode utils you can use them wuth standart ruby function pack:

    str = "\007\007\002\abcde"
    new_string = [str].pack("u")
    original = new_string.unpack("u")
    

    (sample from Hal Fulton's Ruby Way)

提交回复
热议问题