あと、、、
$key = substr sha1_base64($key), 0, 12;
$key =~ tr/+/./; ←これしちゃうのはいくないのかな?