Skip to content

Instantly share code, notes, and snippets.

@avsej
Created January 23, 2010 09:14
Show Gist options
  • Save avsej/284516 to your computer and use it in GitHub Desktop.
Save avsej/284516 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# encoding: utf8
$KCODE="u"
en_ru = { 'q'=>'й', 'w'=>'ц', 'e'=>'у', 'r'=>'к', 't'=>'е', 'y'=>'н',
'u'=>'г', 'i'=>'ш', 'o'=>'щ', 'p'=>'з', '['=>'х', ']'=>'ъ',
'a'=>'ф', 's'=>'ы', 'd'=>'в', 'f'=>'а', 'g'=>'п', 'h'=>'р',
'j'=>'о', 'k'=>'л', 'l'=>'д', ';'=>'ж', "'"=>'э', 'z'=>'я',
'x'=>'ч', 'c'=>'с', 'v'=>'м', 'b'=>'и', 'n'=>'т', 'm'=>'ь',
','=>'б', '.'=>'ю', '`'=>'ё',
'Q'=>'Й', 'W'=>'Ц', 'E'=>'У', 'R'=>'К', 'T'=>'Е', 'Y'=>'Н',
'U'=>'Г', 'I'=>'Ш', 'O'=>'Щ', 'P'=>'З', '{'=>'Х', '}'=>'Ъ',
'A'=>'Ф', 'S'=>'Ы', 'D'=>'В', 'F'=>'А', 'G'=>'П', 'H'=>'Р',
'J'=>'О', 'K'=>'Л', 'L'=>'Д', ':'=>'Ж', '"'=>'Э', 'Z'=>'Я',
'X'=>'Ч', 'C'=>'С', 'V'=>'М', 'B'=>'И', 'N'=>'Т', 'M'=>'Ь',
'<'=>'Б', '>'=>'Ю', '~'=>'Ё' }
ru_en = en_ru.invert
puts ARGF.read.scan(/./).map{|c| en_ru[c] || c}.join
# puts ARGF.read.scan(/./).map{|c| ru_en[c] || c}.join
$ echo "gj heccrb" | ruby decode.rb
по русски
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment