DEV Community

Discussion on: Simple String encryption in Rails

Collapse
 
bartosz profile image
Bartosz Wójcik

You might be interested in this thing called StringEncrypt.

stringencrypt.com/

It can take your strings, encrypt them with random algorithm and generate clean decryption Ruby code, for example:

# encrypted with https://www.stringencrypt.com (v1.3.0) [Ruby]
# test = "hello dev.to"
test = "\u8C71\u0C61\u3C51\u2441\u1431\u7424\u1C12\uFC01\u5BF0\u03E2\u3BD0\uCBCF"

test.codepoints.each_with_index do |zjxxo, npbyw|
  zjxxo = ((zjxxo << 12) | ( (zjxxo & 0xFFFF) >> 4)) & 0xFFFF
  zjxxo -= 0x6C44
  zjxxo += npbyw
  zjxxo += 0xE0A5
  zjxxo = ((zjxxo << 7) | ( (zjxxo & 0xFFFF) >> 9)) & 0xFFFF
  zjxxo += 1
  zjxxo += npbyw
  zjxxo += 0xAE9C
  zjxxo ^= 0x5839
  zjxxo = ((zjxxo << 2) | ( (zjxxo & 0xFFFF) >> 14)) & 0xFFFF
  zjxxo ^= 0x6B00
  zjxxo += npbyw
  test[npbyw] = [zjxxo & 0xFFFF].pack('U').force_encoding('UTF-8')
end

puts test