base64-encoding
base64やURLエンコード、ハッシュ化など、様々な形式のエンコードとデコードを行うためのSkill。
📜 元の英語説明(参考)
Encoding and decoding utilities — base64, URL encoding, hex, and hashing. Use when user mentions "base64", "encode", "decode", "url encode", "urlencode", "hex", "hash", "sha256", "md5", "checksum", "jwt decode", "binary to text", or converting between encoding formats.
🇯🇵 日本人クリエイター向け解説
base64やURLエンコード、ハッシュ化など、様々な形式のエンコードとデコードを行うためのSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o base64-encoding.zip https://jpskill.com/download/6065.zip && unzip -o base64-encoding.zip && rm base64-encoding.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/6065.zip -OutFile "$d\base64-encoding.zip"; Expand-Archive "$d\base64-encoding.zip" -DestinationPath $d -Force; ri "$d\base64-encoding.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
base64-encoding.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
base64-encodingフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-17
- 取得日時
- 2026-05-17
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
エンコードおよびデコードユーティリティ
Base64 エンコード/デコード
文字列
# Encode
echo -n 'hello world' | base64
# Decode (macOS)
echo 'aGVsbG8gd29ybGQ=' | base64 -D
# Decode (Linux)
echo 'aGVsbG8gd29ybGQ=' | base64 -d
ファイル
# Encode a file
base64 < input.bin > output.b64
# Decode to file (macOS)
base64 -D < output.b64 > restored.bin
# Decode to file (Linux)
base64 -d < output.b64 > restored.bin
Stdin パイプ
curl -s https://example.com/image.png | base64
macOS と Linux の比較
| 操作 | macOS | Linux |
|---|---|---|
| デコード | base64 -D |
base64 -d |
| 折り返し | base64 -b 76 |
base64 -w 76 |
ポータブル: base64 --decode 2>/dev/null || base64 -D
URL エンコード/デコード
# Python 3
python3 -c "import urllib.parse; print(urllib.parse.quote('hello world&foo=bar'))"
python3 -c "import urllib.parse; print(urllib.parse.unquote('hello%20world%26foo%3Dbar'))"
# Node.js
node -e "console.log(encodeURIComponent('hello world&foo=bar'))"
node -e "console.log(decodeURIComponent('hello%20world%26foo%3Dbar'))"
Hex エンコード/デコード
# String to hex
echo -n 'hello' | xxd -p
# Output: 68656c6c6f
# Hex to string
echo '68656c6c6f' | xxd -r -p
# Output: hello
# File to hex dump
xxd input.bin
# Compact hex (no formatting)
xxd -p input.bin
# Using od
echo -n 'hello' | od -A n -t x1 | tr -d ' \n'
# Hex to bytes with printf
printf '\x68\x65\x6c\x6c\x6f'
ハッシュ
文字列のハッシュ化
# MD5
echo -n 'hello' | md5sum # Linux
echo -n 'hello' | md5 # macOS
# SHA-1
echo -n 'hello' | sha1sum # Linux
echo -n 'hello' | shasum -a 1 # macOS
# SHA-256
echo -n 'hello' | sha256sum # Linux
echo -n 'hello' | shasum -a 256 # macOS
# SHA-512
echo -n 'hello' | sha512sum # Linux
echo -n 'hello' | shasum -a 512 # macOS
末尾の改行をハッシュ化しないように echo -n を使用してください。
ファイルのハッシュ化
sha256sum myfile.tar.gz # Linux
shasum -a 256 myfile.tar.gz # macOS
OpenSSL (クロスプラットフォーム)
openssl dgst -sha256 myfile.tar.gz
echo -n 'hello' | openssl dgst -sha256
チェックサムによるファイルの整合性検証
# Generate checksum file
sha256sum release.tar.gz > release.sha256
# Verify (Linux)
sha256sum -c release.sha256
# Verify (macOS)
shasum -a 256 -c release.sha256
# Quick inline comparison
EXPECTED="e3b0c44298fc1c149afbf4c8996fb924..."
ACTUAL=$(sha256sum downloaded.tar.gz | awk '{print $1}')
[ "$EXPECTED" = "$ACTUAL" ] && echo "OK" || echo "MISMATCH"
ライブラリなしで JWT をデコードする
JWT は、ヘッダー、ペイロード、署名の3つのドット区切りの base64url セグメントで構成されています。
JWT="eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U"
# Decode header
echo "$JWT" | cut -d. -f1 | tr '_-' '/+' | base64 -d 2>/dev/null || \
echo "$JWT" | cut -d. -f1 | tr '_-' '/+' | base64 -D
# Decode payload
echo "$JWT" | cut -d. -f2 | tr '_-' '/+' | base64 -d 2>/dev/null || \
echo "$JWT" | cut -d. -f2 | tr '_-' '/+' | base64 -D
Base64url は + と / の代わりに - と _ を使用します。tr コールは元に戻します。必要に応じてパディングを追加してください。
decode_b64url() {
local d="$1" pad=$(( 4 - ${#1} % 4 ))
[ "$pad" -lt 4 ] && d="${d}$(printf '%0.s=' $(seq 1 $pad))"
echo "$d" | tr '_-' '/+' | base64 -d 2>/dev/null || echo "$d" | tr '_-' '/+' | base64 -D
}
decode_b64url "$(echo "$JWT" | cut -d. -f2)"
ランダムな文字列を生成する
# Alphanumeric, 32 chars
cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | head -c 32
# Hex string, 32 chars
openssl rand -hex 16
# Base64 string
openssl rand -base64 24
# URL-safe random string
openssl rand -base64 32 | tr '+/' '-_' | tr -d '='
# UUID-like
cat /proc/sys/kernel/random/uuid 2>/dev/null || uuidgen
HTML エンティティ エンコード/デコード
# Encode (Python)
python3 -c "import html; print(html.escape('<div class=\"x\">&</div>'))"
# Output: <div class="x">&</div>
# Decode (Python)
python3 -c "import html; print(html.unescape('<div>hello</div>'))"
# Decode (Perl)
perl -MHTML::Entities -e 'print decode_entities("<p>hello</p>")'
Unicode エスケープ/アンエスケープ
# Unescape \uXXXX sequences (Python)
python3 -c "print('\\u0048\\u0065\\u006c\\u006c\\u006f')"
# Escape string to \uXXXX
python3 -c "print(''.join(f'\\\\u{ord(c):04x}' for c in 'Hello'))"
# Unescape JSON unicode (jq)
echo '"\\u0048\\u0065\\u006c\\u006c\\u006f"' | jq -r .
# UTF-8 hex bytes to character
printf '\xc3\xa9' # prints: e with accent (é)
# Character to UTF-8 hex
echo -n 'é' | xxd -p
共通のパターン
JSON 埋め込み用にファイルをエンコードする
BASE64=$(base64 < image.png | tr -d '\n')
echo "{\"image\": \"data:image/png;base64,${BASE64}\"}"
API レスポンスから base64 フィールドをデコードする
curl -s https://api.example.com/data | jq -r '.content' | base64 -d
ダウンロードのチェックサムを検証する
curl -LO https://example.com/release.tar.gz
curl -sL https://example.com/release.sha256 | sha256sum -c -
API キーを生成する
openssl rand -base64 32 | tr -d '\n'
openssl rand -hex 32
Basic Auth の認証情報をエンコードする
echo -n 'user:password' | base64
# Use in header: Authorization: Basic dXNlcjpwYXNzd29yZA==
クイックリファレンス
| タスク | コマンド |
|---|---|
| Base64 文字列をエンコードする | echo -n 'text' \| base64 |
| Base64 デコード (macOS) | echo 'data' \| base64 -D |
| Base64 デコード (Linux) | echo 'data' \| base64 -d |
| URL エンコード | python3 -c "import urllib.parse; print(urllib.parse.quote('...'))" |
| URL デコード | python3 -c "import urllib.parse; print(urllib.parse.unquote |
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Encoding and Decoding Utilities
Base64 Encode/Decode
String
# Encode
echo -n 'hello world' | base64
# Decode (macOS)
echo 'aGVsbG8gd29ybGQ=' | base64 -D
# Decode (Linux)
echo 'aGVsbG8gd29ybGQ=' | base64 -d
File
# Encode a file
base64 < input.bin > output.b64
# Decode to file (macOS)
base64 -D < output.b64 > restored.bin
# Decode to file (Linux)
base64 -d < output.b64 > restored.bin
Stdin pipe
curl -s https://example.com/image.png | base64
macOS vs Linux
| Operation | macOS | Linux |
|---|---|---|
| Decode | base64 -D |
base64 -d |
| Wrap cols | base64 -b 76 |
base64 -w 76 |
Portable: base64 --decode 2>/dev/null || base64 -D
URL Encoding/Decoding
# Python 3
python3 -c "import urllib.parse; print(urllib.parse.quote('hello world&foo=bar'))"
python3 -c "import urllib.parse; print(urllib.parse.unquote('hello%20world%26foo%3Dbar'))"
# Node.js
node -e "console.log(encodeURIComponent('hello world&foo=bar'))"
node -e "console.log(decodeURIComponent('hello%20world%26foo%3Dbar'))"
Hex Encode/Decode
# String to hex
echo -n 'hello' | xxd -p
# Output: 68656c6c6f
# Hex to string
echo '68656c6c6f' | xxd -r -p
# Output: hello
# File to hex dump
xxd input.bin
# Compact hex (no formatting)
xxd -p input.bin
# Using od
echo -n 'hello' | od -A n -t x1 | tr -d ' \n'
# Hex to bytes with printf
printf '\x68\x65\x6c\x6c\x6f'
Hashing
String hashing
# MD5
echo -n 'hello' | md5sum # Linux
echo -n 'hello' | md5 # macOS
# SHA-1
echo -n 'hello' | sha1sum # Linux
echo -n 'hello' | shasum -a 1 # macOS
# SHA-256
echo -n 'hello' | sha256sum # Linux
echo -n 'hello' | shasum -a 256 # macOS
# SHA-512
echo -n 'hello' | sha512sum # Linux
echo -n 'hello' | shasum -a 512 # macOS
Use echo -n to avoid hashing the trailing newline.
File hashing
sha256sum myfile.tar.gz # Linux
shasum -a 256 myfile.tar.gz # macOS
OpenSSL (cross-platform)
openssl dgst -sha256 myfile.tar.gz
echo -n 'hello' | openssl dgst -sha256
Verify File Integrity with Checksums
# Generate checksum file
sha256sum release.tar.gz > release.sha256
# Verify (Linux)
sha256sum -c release.sha256
# Verify (macOS)
shasum -a 256 -c release.sha256
# Quick inline comparison
EXPECTED="e3b0c44298fc1c149afbf4c8996fb924..."
ACTUAL=$(sha256sum downloaded.tar.gz | awk '{print $1}')
[ "$EXPECTED" = "$ACTUAL" ] && echo "OK" || echo "MISMATCH"
JWT Decode Without a Library
A JWT has three dot-separated base64url segments: header, payload, signature.
JWT="eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U"
# Decode header
echo "$JWT" | cut -d. -f1 | tr '_-' '/+' | base64 -d 2>/dev/null || \
echo "$JWT" | cut -d. -f1 | tr '_-' '/+' | base64 -D
# Decode payload
echo "$JWT" | cut -d. -f2 | tr '_-' '/+' | base64 -d 2>/dev/null || \
echo "$JWT" | cut -d. -f2 | tr '_-' '/+' | base64 -D
Base64url uses - and _ instead of + and /. The tr call converts back. Add padding if needed:
decode_b64url() {
local d="$1" pad=$(( 4 - ${#1} % 4 ))
[ "$pad" -lt 4 ] && d="${d}$(printf '%0.s=' $(seq 1 $pad))"
echo "$d" | tr '_-' '/+' | base64 -d 2>/dev/null || echo "$d" | tr '_-' '/+' | base64 -D
}
decode_b64url "$(echo "$JWT" | cut -d. -f2)"
Generate Random Strings
# Alphanumeric, 32 chars
cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | head -c 32
# Hex string, 32 chars
openssl rand -hex 16
# Base64 string
openssl rand -base64 24
# URL-safe random string
openssl rand -base64 32 | tr '+/' '-_' | tr -d '='
# UUID-like
cat /proc/sys/kernel/random/uuid 2>/dev/null || uuidgen
HTML Entity Encode/Decode
# Encode (Python)
python3 -c "import html; print(html.escape('<div class=\"x\">&</div>'))"
# Output: <div class="x">&</div>
# Decode (Python)
python3 -c "import html; print(html.unescape('<div>hello</div>'))"
# Decode (Perl)
perl -MHTML::Entities -e 'print decode_entities("<p>hello</p>")'
Unicode Escape/Unescape
# Unescape \uXXXX sequences (Python)
python3 -c "print('\\u0048\\u0065\\u006c\\u006c\\u006f')"
# Escape string to \uXXXX
python3 -c "print(''.join(f'\\\\u{ord(c):04x}' for c in 'Hello'))"
# Unescape JSON unicode (jq)
echo '"\\u0048\\u0065\\u006c\\u006c\\u006f"' | jq -r .
# UTF-8 hex bytes to character
printf '\xc3\xa9' # prints: e with accent (é)
# Character to UTF-8 hex
echo -n 'é' | xxd -p
Common Patterns
Encode a file for JSON embedding
BASE64=$(base64 < image.png | tr -d '\n')
echo "{\"image\": \"data:image/png;base64,${BASE64}\"}"
Decode a base64 field from an API response
curl -s https://api.example.com/data | jq -r '.content' | base64 -d
Verify a download checksum
curl -LO https://example.com/release.tar.gz
curl -sL https://example.com/release.sha256 | sha256sum -c -
Generate an API key
openssl rand -base64 32 | tr -d '\n'
openssl rand -hex 32
Encode credentials for Basic Auth
echo -n 'user:password' | base64
# Use in header: Authorization: Basic dXNlcjpwYXNzd29yZA==
Quick Reference
| Task | Command |
|---|---|
| Base64 encode string | echo -n 'text' \| base64 |
| Base64 decode (macOS) | echo 'data' \| base64 -D |
| Base64 decode (Linux) | echo 'data' \| base64 -d |
| URL encode | python3 -c "import urllib.parse; print(urllib.parse.quote('...'))" |
| URL decode | python3 -c "import urllib.parse; print(urllib.parse.unquote('...'))" |
| Hex encode | echo -n 'text' \| xxd -p |
| Hex decode | echo 'hex' \| xxd -r -p |
| MD5 hash | echo -n 'text' \| openssl dgst -md5 |
| SHA-256 hash | echo -n 'text' \| openssl dgst -sha256 |
| SHA-256 file | openssl dgst -sha256 file.tar.gz |
| Verify checksum | sha256sum -c checksums.sha256 |
| JWT decode payload | echo $JWT \| cut -d. -f2 \| tr '_-' '/+' \| base64 -d |
| Random hex (32 chars) | openssl rand -hex 16 |
| Random base64 | openssl rand -base64 24 |
| HTML encode | python3 -c "import html; print(html.escape('...'))" |
| HTML decode | python3 -c "import html; print(html.unescape('...'))" |
| Unicode unescape | python3 -c "print('\\u0048\\u0065')" |
| Basic Auth header | echo -n 'user:pass' \| base64 |