Skip to content

Instantly share code, notes, and snippets.

@abyssluke
Last active February 7, 2021 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abyssluke/4f34a91fea4e60c06a6c939ac2ead62b to your computer and use it in GitHub Desktop.
Save abyssluke/4f34a91fea4e60c06a6c939ac2ead62b to your computer and use it in GitHub Desktop.
Base64を適当にひらがなに置き換えてしまうやーつ
<?php
class base64kana {
const CNV_TABLE = array(
"A" => "あ", "B" => "い", "C" => "う", "D" => "え", "E" => "お",
"F" => "か", "G" => "き", "H" => "く", "I" => "け", "J" => "こ",
"K" => "さ", "L" => "し", "M" => "す", "N" => "せ", "O" => "そ",
"P" => "た", "Q" => "ち", "R" => "つ", "S" => "て", "T" => "と",
"U" => "な", "V" => "に", "W" => "ぬ", "X" => "ね", "Y" => "の",
"Z" => "は", "a" => "ひ", "b" => "ふ", "c" => "へ", "d" => "ほ",
"e" => "ま", "f" => "み", "g" => "む", "h" => "め", "i" => "も",
"j" => "や", "k" => "ゆ", "l" => "よ",
"m" => "ら", "n" => "り", "o" => "る", "p" => "れ", "q" => "ろ",
"r" => "わ",
"s" => "が", "t" => "ぎ", "u" => "ぐ", "v" => "げ", "w" => "ご",
"x" => "ざ", "y" => "じ", "z" => "ず", "0" => "ぜ", "1" => "ぞ",
"2" => "だ", "3" => "ぢ", "4" => "づ", "5" => "で", "6" => "ど",
"7" => "ば", "8" => "び", "9" => "ぶ", "+" => "べ", "/" => "ぼ",
"=" => "ん",
);
public function encode($str){
$tmp = base64_encode($str);
return str_replace(array_keys(self::CNV_TABLE), array_values(self::CNV_TABLE), $tmp);
}
public function decode($str){
$tmp = str_replace(array_values(self::CNV_TABLE), array_keys(self::CNV_TABLE), $str);
return base64_decode($tmp);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment