소스 정보
- 저장소
- ffsshhttiikk/opencode-agents-skills
- 최근 소스 활동
- 2026년 2월 28일 22:51
- 감지된 SKILL.md 언어
- 영어
- 스타
- 2
- 포크
- 2
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
SOC 직업 분류 기준
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/ffsshhttiikk/opencode-agents-skills --skill encryption명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SKILL.md 표시 중
| name | encryption |
| description | Data encryption best practices and implementation |
| license | MIT |
| compatibility | opencode |
| metadata | {"audience":"developers","category":"security"} |
When implementing encryption or handling sensitive data.
import os
import base64
from cryptography.fernet import Fernet
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
from cryptography.hazmat.primitives.asymmetric import rsa, padding
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.backends import default_backend
class EncryptionService:
"""Encryption service for sensitive data."""
def __init__(self, master_key: bytes = None):
self.master_key = master_key or os.environ.get("ENCRYPTION_KEY").encode()
self.fernet = Fernet(self._derive_key(self.master_key, b"fernet"))
def _derive_key(self, key: bytes, salt: bytes) -> bytes:
"""Derive a key from master key using PBKDF2."""
kdf = PBKDF2HMAC(
algorithm=hashes.SHA256(),
length=32,
salt=salt,
iterations=480000,
backend=default_backend()
)
return base64.urlsafe_b64encode(kdf.derive(key))
def encrypt(self, plaintext: str) -> str:
"""Encrypt plaintext string."""
if isinstance(plaintext, str):
plaintext = plaintext.encode()
encrypted = self.fernet.encrypt(plaintext)
return encrypted.decode()
def decrypt(self, ciphertext: str) -> str:
"""Decrypt ciphertext string."""
if isinstance(ciphertext, str):
ciphertext = ciphertext.encode()
decrypted = self.fernet.decrypt(ciphertext)
return decrypted.decode()
def encrypt_file(self, input_path: str, output_path: str) -> None:
"""Encrypt a file."""
with open(input_path, 'rb') as f:
data = f.read()
encrypted = self.fernet.encrypt(data)
with open(output_path, 'wb') as f:
f.write(encrypted)
def decrypt_file(self, input_path: str, output_path: str) -> None:
"""Decrypt a file."""
with open(input_path, 'rb') as f:
data = f.read()
decrypted = self.fernet.decrypt(data)
with open(output_path, 'wb') as f:
f.write(decrypted)
class AsymmetricEncryption:
"""Asymmetric encryption for key exchange and signatures."""
def __init__(self):
self.private_key = rsa.generate_private_key(
public_exponent=65537,
key_size=2048,
backend=default_backend()
)
self.public_key = self.private_key.public_key()
def encrypt(self, plaintext: bytes) -> bytes:
"""Encrypt with public key."""
return self.public_key.encrypt(
plaintext,
padding.OAEP(
mgf=padding.MGF1(algorithm=hashes.SHA256()),
algorithm=hashes.SHA256(),
label=None
)
)
def decrypt(self, ciphertext: bytes) -> bytes:
"""Decrypt with private key."""
return self.private_key.decrypt(
ciphertext,
padding.OAEP(
mgf=padding.MGF1(algorithm=hashes.SHA256()),
algorithm=hashes.SHA256(),
label=None
)
)
def get_public_key_pem(self) -> bytes:
"""Get public key in PEM format."""
return self.public_key.public_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PublicFormat.SubjectPublicKeyInfo
)
def sign(self, data: bytes) -> bytes:
"""Sign data with private key."""
return self.private_key.sign(
data,
padding.PKCS1v15(),
hashes.SHA256()
)
def verify_signature(self, data: bytes, signature: bytes) -> bool:
"""Verify signature with public key."""
try:
self.public_key.verify(
signature,
data,
padding.PKCS1v15(),
hashes.SHA256()
)
return True
except:
return False
from dataclasses import dataclass
from typing import Dict, Any
import json
@dataclass
class EncryptedField:
"""Encrypted field value."""
ciphertext: str
iv: str
algorithm: str = "AES-256-GCM"
class FieldEncryption:
"""Encrypt specific fields in data."""
def __init__(self, encryption_service: EncryptionService):
self.encryption = encryption_service
def encrypt_fields(
self,
data: Dict[str, Any],
fields_to_encrypt: list[str]
) -> Dict[str, Any]:
"""Encrypt specific fields in data."""
encrypted = data.copy()
for field in fields_to_encrypt:
if field in encrypted and encrypted[field]:
encrypted[field] = self.encryption.encrypt(
str(encrypted[field])
)
return encrypted
def decrypt_fields(
self,
data: Dict[, ],
fields_to_decrypt: []
) -> [, ]:
decrypted = data.copy()
field fields_to_decrypt:
field decrypted decrypted[field]:
:
decrypted[field] = .encryption.decrypt(
decrypted[field]
)
:
decrypted
pydantic BaseModel, Field
():
:
name:
email:
() -> :
._decrypted_ssn
():
._encrypted_ssn = value
:
json_encoders = {
EncryptedField: v: v.ciphertext
}
import os
import json
from datetime import datetime, timedelta
from cryptography.fernet import Fernet
class KeyRotationManager:
"""Manage encryption key rotation."""
def __init__(self, key_storage_path: str):
self.key_storage_path = key_storage_path
self.current_key_id = None
self.keys: Dict[str, dict] = self._load_keys()
def _load_keys(self) -> dict:
"""Load keys from storage."""
if os.path.exists(self.key_storage_path):
with open(self.key_storage_path, 'r') as f:
return json.load(f)
return {}
def _save_keys(self) -> None:
"""Save keys to storage."""
with open(self.key_storage_path, 'w') as f:
json.dump(self.keys, f)
def generate_key() -> :
key_id = key_id
key = Fernet.generate_key().decode()
.keys[key_id] = {
: key,
: datetime.utcnow().isoformat(),
: ,
: ,
}
.current_key_id = key_id
._save_keys()
key_id
() -> :
key_id .keys:
KeyError()
.keys[key_id][] =
.keys[key_id][] = datetime.utcnow().isoformat()
.generate_key()
() -> :
.current_key_id:
.generate_key()
.keys[.current_key_id][]
() -> :
[
{: k, **v}
k, v .keys.items()
v[] [, ]
]
# Nginx TLS configuration
# /etc/nginx/nginx.conf
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/ssl/certs/certificate.crt;
ssl_certificate_key /etc/ssl/private/private.key;
# TLS configuration
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
ssl_prefer_server_ciphers off;
# HSTS
add_header Strict-Transport-Security "max-age=63072000" always;
# OCSP Stapling
ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 5s;
# Security headers
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Content-Security-Policy "default-src 'self'";
location / {
proxy_pass http://localhost:8000;
}
}
# Python SSL context for HTTPS
import ssl
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
# Load certificate and key
ssl_context.load_cert_chain(
certfile="/etc/ssl/certs/certificate.crt",
keyfile="/etc/ssl/private/private.key"
)
# Set secure protocols
ssl_context.minimum_version = ssl.TLSVersion.TLSv1_2
# Set cipher suites
ssl_context.set_ciphers('ECDHE+AESGCM:DHE+AESGCM:ECDHE+CHACHA20:DHE+CHACHA20')
Encryption Best Practices:
1. Use strong algorithms
- AES-256 for symmetric
- RSA-2048+ for asymmetric
- SHA-256 for hashing
2. Manage keys properly
- Use key management services
- Rotate keys regularly
- Never hardcode keys
3. Encrypt sensitive data
- PII, passwords, tokens
- Database fields
- Files at rest
4. Use TLS everywhere
- HTTPS for all traffic
- Certificate pinning
- HSTS headers
5. Don't roll your own crypto
- Use established libraries
- Don't implement algorithms
6. Key separation
- Different keys for different purposes
- Development vs production
7. Secure key storage
- Hardware security modules
- Cloud KMS
- Vault
8. Audit encryption
- Log encryption operations
- Monitor key usage
- Alert on anomalies
9. Plan for key rotation
- Automated rotation
- Graceful transitions
- Backward compatibility
10. Protect against side channels
- Constant-time operations
- Secure memory handling