Advertisement
Narzew

Text to Int Encoder & Decode Helper

Nov 29th, 2012
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.17 KB | None | 0 0
  1. #######################################################
  2. ##** Text to Int Encoder
  3. ##** Text to Int Decode Helper
  4. ##** Copyright by Narzew
  5. ##** http://pokepark.tk
  6. ##** 29.11.12
  7. #######################################################
  8.  
  9. #######################################################
  10. ##**encode_ints
  11. ##**Encodes string to int (one-way!)
  12. #######################################################
  13.  
  14. def encode_ints(x)
  15.     return x.downcase.tr('abcdefghijklmnopqrstuvwxyz','22233344455566677778889999')
  16. end
  17.  
  18. #######################################################
  19. ##**decode_ints
  20. ##**Helps decoding ints making possibilities to each int
  21. #######################################################
  22.  
  23. def decode_ints(x)
  24.     return x.gsub('2','(abc)').gsub('3','(def)').gsub('4','(ghi)').gsub('5','(jkl)').gsub('6','(mno)').gsub('7', '(pqrs)').gsub('8', '(tuv)').gsub('9', '(wxyz)')
  25. end
  26.  
  27. #######################################################
  28. ##**End of script
  29. #######################################################
  30.  
  31. #######################################################
  32. ##**Copyright by Narzew
  33. ##**http://pokepark.tk
  34. #######################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement