9
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

裏GETWILD'89(復号編)

Posted at

GetWild Advent Calendar 2016 の 4日目に !!!!げっ!げっえんたー!!!!げっ!げっげっ!!!!げっげっげっ! !!!!げっげっげっえんたー!!!!げっ!わいーげっ!!!!げっ!えんたー!!!!!げっ!げっ! !!!!!わいーげっえんたー!!!!!えんたーわいー!!!!!!えんた ーわいーげっ という記事が投稿されていた。
このタイトルおよび本文は任意の文字列を , げっ , わいー , えんたー に置き換えたものだけど、面白そうだったのでrubyで復号してみた。

と言っても単純で、逆のことをするだけ。

input = "!えんたー!!げっげっ!えんたー!えんたー!!げっわいーえんたーわいーわいー!わいーわいー!げっわいー!げっ!えんたーわいーわいー!わいーえんたー!えんたー!!げっわいーえんたーえんたー"

binaries = input.gsub("!", "00").gsub("げっ", "01").gsub("わいー", "10").gsub("えんたー", "11").gsub(" ", "")
binaries.each_char.each_slice(16).
  map { |chars| chars.join("").to_i(2) }.
  map { |chars| chars.chr("UTF-8") }.
  join
  • それぞれの単語をビット列に見立てた文字に置換
  • 16文字(2バイト)毎に区切り、数値変換(文字コード)
  • UTF-8に変換

※ 厳密にはスペースの扱いで元の文字列と同一にはできていないけど、まあ文意は分かるということで。

9
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?