cert folder have many of fake certificate image and their code, realistic, fake, no_copy, no_copy, no_copy, warning, no_copy
Browse files- cert/cert.py +128 -0
- cert/cert10.py +261 -0
- cert/cert11.py +362 -0
- cert/cert12.py +368 -0
- cert/cert13.py +161 -0
- cert/cert2.py +128 -0
- cert/cert3.py +192 -0
- cert/cert4.py +235 -0
- cert/cert5.py +152 -0
- cert/cert6.py +140 -0
- cert/cert7.py +194 -0
- cert/cert8.py +229 -0
- cert/cert9.py +231 -0
- cert/certificate_public_key.pem +14 -0
- cert/encrypt_info_to_qrcode.py +46 -0
- cert/image_details.py +45 -0
- cert/image_details2.py +30 -0
- cert/info_to_qrcode.py +34 -0
- cert/private_key.pem +27 -0
- cert/pub_key.py +18 -0
- cert/public_key.pem +9 -0
- cert/verifier.py +115 -0
cert/cert.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import qrcode
|
| 2 |
+
from PIL import Image, ImageDraw, ImageFont
|
| 3 |
+
import hashlib
|
| 4 |
+
|
| 5 |
+
# ===== Certificate Info =====
|
| 6 |
+
name = "Yasin"
|
| 7 |
+
user_id = "YSNRFD"
|
| 8 |
+
membership_date = "April 1, 2023"
|
| 9 |
+
issued_date = "June 28, 2025"
|
| 10 |
+
certificate_id = "OPENAI-YSN-APR2023-CERT1001"
|
| 11 |
+
signed_by = "ChatGPT-4o"
|
| 12 |
+
model_id = "GPT4O-REP-TRUST-2025"
|
| 13 |
+
issuer = "OpenAI, Inc."
|
| 14 |
+
|
| 15 |
+
# Prepare data string for digital signature
|
| 16 |
+
data_string = f"""
|
| 17 |
+
Name: {name}
|
| 18 |
+
User ID: {user_id}
|
| 19 |
+
Membership Date: {membership_date}
|
| 20 |
+
Issued Date: {issued_date}
|
| 21 |
+
Certificate ID: {certificate_id}
|
| 22 |
+
Signed By: {signed_by}
|
| 23 |
+
Model ID: {model_id}
|
| 24 |
+
Issuer: {issuer}
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
# Generate SHA-256 digital signature
|
| 28 |
+
digital_signature = hashlib.sha256(data_string.encode('utf-8')).hexdigest()
|
| 29 |
+
verification_code = f"VER-{digital_signature[:8].upper()}-{certificate_id[-4:]}"
|
| 30 |
+
|
| 31 |
+
# Create QR code from digital signature
|
| 32 |
+
qr = qrcode.QRCode(box_size=7, border=3)
|
| 33 |
+
qr.add_data(digital_signature)
|
| 34 |
+
qr.make(fit=True)
|
| 35 |
+
qr_img = qr.make_image(fill_color="black", back_color="white").convert("RGBA")
|
| 36 |
+
|
| 37 |
+
# Load fonts with fallback
|
| 38 |
+
try:
|
| 39 |
+
font_title = ImageFont.truetype("arialbd.ttf", 30)
|
| 40 |
+
font_header = ImageFont.truetype("arialbd.ttf", 18)
|
| 41 |
+
font_text = ImageFont.truetype("arial.ttf", 16)
|
| 42 |
+
font_small = ImageFont.truetype("arial.ttf", 14)
|
| 43 |
+
except:
|
| 44 |
+
font_title = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 30)
|
| 45 |
+
font_header = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 18)
|
| 46 |
+
font_text = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 16)
|
| 47 |
+
font_small = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 14)
|
| 48 |
+
|
| 49 |
+
# Create certificate canvas
|
| 50 |
+
width, height = 850, 520
|
| 51 |
+
certificate = Image.new("RGB", (width, height), "#fffefa")
|
| 52 |
+
draw = ImageDraw.Draw(certificate)
|
| 53 |
+
|
| 54 |
+
# Background rectangle and divider line
|
| 55 |
+
draw.rectangle([(15, 15), (width-15, height-15)], outline="#555555", width=3)
|
| 56 |
+
draw.line([(20, 80), (width-20, 80)], fill="#999999", width=2)
|
| 57 |
+
|
| 58 |
+
# Title text
|
| 59 |
+
draw.text((40, 30), "OpenAI – Certificate of Membership", font=font_title, fill="#222222")
|
| 60 |
+
|
| 61 |
+
# Certificate info lines
|
| 62 |
+
info_lines = [
|
| 63 |
+
f"Name: {name}",
|
| 64 |
+
f"User ID: {user_id}",
|
| 65 |
+
f"Membership Date: {membership_date}",
|
| 66 |
+
f"Issued Date: {issued_date}",
|
| 67 |
+
f"Certificate ID: {certificate_id}",
|
| 68 |
+
f"Signed By: {signed_by}",
|
| 69 |
+
f"Model ID: {model_id}",
|
| 70 |
+
f"Issuer: {issuer}",
|
| 71 |
+
]
|
| 72 |
+
|
| 73 |
+
y_text = 100
|
| 74 |
+
for line in info_lines:
|
| 75 |
+
draw.text((40, y_text), line, font=font_text, fill="#333333")
|
| 76 |
+
y_text += 30
|
| 77 |
+
|
| 78 |
+
# Verification code
|
| 79 |
+
draw.text((40, y_text + 10), f"Verification Code: {verification_code}", font=font_header, fill="#444444")
|
| 80 |
+
|
| 81 |
+
# Digital signature label and text
|
| 82 |
+
draw.text((40, y_text + 50), "SHA-256 Digital Signature:", font=font_header, fill="#222222")
|
| 83 |
+
|
| 84 |
+
sig_1 = digital_signature[:len(digital_signature)//2]
|
| 85 |
+
sig_2 = digital_signature[len(digital_signature)//2:]
|
| 86 |
+
draw.text((40, y_text + 80), sig_1, font=font_small, fill="#555555")
|
| 87 |
+
draw.text((40, y_text + 100), sig_2, font=font_small, fill="#555555")
|
| 88 |
+
|
| 89 |
+
# Paste QR code on bottom right
|
| 90 |
+
qr_size = 150
|
| 91 |
+
qr_position = (width - qr_size - 40, height - qr_size - 40)
|
| 92 |
+
qr_img = qr_img.resize((qr_size, qr_size), Image.Resampling.LANCZOS)
|
| 93 |
+
certificate.paste(qr_img, qr_position, qr_img)
|
| 94 |
+
|
| 95 |
+
# Draw a professional OpenAI seal
|
| 96 |
+
seal_diameter = 140
|
| 97 |
+
seal = Image.new("RGBA", (seal_diameter, seal_diameter), (255, 255, 255, 0))
|
| 98 |
+
seal_draw = ImageDraw.Draw(seal)
|
| 99 |
+
|
| 100 |
+
# Simple radial gradient circle for seal
|
| 101 |
+
for i in range(seal_diameter//2, 0, -1):
|
| 102 |
+
color_val = 40 + int((seal_diameter//2 - i) * 1.5)
|
| 103 |
+
color = (color_val, color_val, color_val, 255)
|
| 104 |
+
seal_draw.ellipse(
|
| 105 |
+
[seal_diameter//2 - i, seal_diameter//2 - i, seal_diameter//2 + i, seal_diameter//2 + i],
|
| 106 |
+
fill=color
|
| 107 |
+
)
|
| 108 |
+
|
| 109 |
+
# Seal text with shadow
|
| 110 |
+
# Seal text with shadow
|
| 111 |
+
text = "OpenAI"
|
| 112 |
+
bbox = seal_draw.textbbox((0, 0), text, font=font_header)
|
| 113 |
+
w = bbox[2] - bbox[0]
|
| 114 |
+
h = bbox[3] - bbox[1]
|
| 115 |
+
text_pos = ((seal_diameter - w)//2, (seal_diameter - h)//2)
|
| 116 |
+
|
| 117 |
+
# سایه
|
| 118 |
+
seal_draw.text((text_pos[0]+2, text_pos[1]+2), text, font=font_header, fill=(20, 20, 20, 255))
|
| 119 |
+
# متن اصلی
|
| 120 |
+
seal_draw.text(text_pos, text, font=font_header, fill=(240, 240, 240, 255))
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
# Paste seal on top right
|
| 124 |
+
certificate.paste(seal, (width - seal_diameter - 40, 40), seal)
|
| 125 |
+
|
| 126 |
+
# Save certificate image
|
| 127 |
+
certificate.save("openai_certificate_yasin_en.png")
|
| 128 |
+
print("✅ Certificate image created: openai_certificate_yasin_en.png")
|
cert/cert10.py
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from PIL import Image, ImageDraw, ImageFont, ImageFilter, ImageEnhance
|
| 2 |
+
import qrcode
|
| 3 |
+
import hashlib
|
| 4 |
+
import random
|
| 5 |
+
import math
|
| 6 |
+
import os
|
| 7 |
+
import base64
|
| 8 |
+
|
| 9 |
+
# برای امضای دیجیتال واقعی:
|
| 10 |
+
from cryptography.hazmat.primitives.asymmetric import rsa, padding
|
| 11 |
+
from cryptography.hazmat.primitives import hashes, serialization
|
| 12 |
+
|
| 13 |
+
# ======== تنظیمات قابل تغییر ========
|
| 14 |
+
CERT_WIDTH, CERT_HEIGHT = 900, 650
|
| 15 |
+
MARGIN = 30
|
| 16 |
+
BACKGROUND_COLOR = (255, 255, 250)
|
| 17 |
+
BORDER_COLOR = (60, 60, 60)
|
| 18 |
+
TITLE_COLOR = (20, 20, 20)
|
| 19 |
+
TEXT_COLOR = (40, 40, 40)
|
| 20 |
+
WATERMARK_COLOR = (60, 60, 60, 25)
|
| 21 |
+
NOISE_INTENSITY = 100000
|
| 22 |
+
|
| 23 |
+
# ======== اطلاعات گواهی ========
|
| 24 |
+
cert_info = {
|
| 25 |
+
"Name": "Yasin",
|
| 26 |
+
"Last Name": "Aryanfard",
|
| 27 |
+
"User ID": "YSNRFD",
|
| 28 |
+
"Membership Date": "April 1, 2023",
|
| 29 |
+
"Issued Date": "June 28, 2025",
|
| 30 |
+
"Certificate ID": "OPENAI-YSN-APR2023-CERT11011010",
|
| 31 |
+
"Signed By": "ChatGPT-4o",
|
| 32 |
+
"Model ID": "GPT4O-REP-TRUST-2025",
|
| 33 |
+
"Issuer": "OpenAI, Inc."
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
# ======== کلیدهای RSA برای امضای دیجیتال ========
|
| 37 |
+
def generate_rsa_keys():
|
| 38 |
+
private_key = rsa.generate_private_key(public_exponent=65537, key_size=2048)
|
| 39 |
+
public_key = private_key.public_key()
|
| 40 |
+
return private_key, public_key
|
| 41 |
+
|
| 42 |
+
private_key, public_key = generate_rsa_keys()
|
| 43 |
+
|
| 44 |
+
# ======== تابع بارگذاری فونت پویا با fallback ========
|
| 45 |
+
def load_font(name, size):
|
| 46 |
+
paths = [
|
| 47 |
+
name,
|
| 48 |
+
os.path.join("/usr/share/fonts/truetype/dejavu/", name),
|
| 49 |
+
os.path.join("/Library/Fonts/", name),
|
| 50 |
+
os.path.join("C:/Windows/Fonts/", name)
|
| 51 |
+
]
|
| 52 |
+
for path in paths:
|
| 53 |
+
try:
|
| 54 |
+
return ImageFont.truetype(path, size)
|
| 55 |
+
except:
|
| 56 |
+
continue
|
| 57 |
+
return ImageFont.load_default()
|
| 58 |
+
|
| 59 |
+
font_title = load_font("timesbd.ttf", 36) # فونت رسمیتر
|
| 60 |
+
font_header = load_font("timesbd.ttf", 20)
|
| 61 |
+
font_text = load_font("times.ttf", 18)
|
| 62 |
+
font_small = load_font("times.ttf", 14)
|
| 63 |
+
|
| 64 |
+
# ======== تولید رشته داده برای امضا دیجیتال ========
|
| 65 |
+
data_string = "\n".join(f"{k}: {v}" for k, v in cert_info.items()).encode('utf-8')
|
| 66 |
+
|
| 67 |
+
# امضای دیجیتال واقعی با کلید خصوصی
|
| 68 |
+
digital_signature_bytes = private_key.sign(
|
| 69 |
+
data_string,
|
| 70 |
+
padding.PSS(
|
| 71 |
+
mgf=padding.MGF1(hashes.SHA256()),
|
| 72 |
+
salt_length=padding.PSS.MAX_LENGTH
|
| 73 |
+
),
|
| 74 |
+
hashes.SHA256()
|
| 75 |
+
)
|
| 76 |
+
|
| 77 |
+
digital_signature = base64.b64encode(digital_signature_bytes).decode('utf-8')
|
| 78 |
+
verification_code = f"VER-{hashlib.sha256(data_string).hexdigest()[:8].upper()}-{cert_info['Certificate ID'][-4:]}"
|
| 79 |
+
|
| 80 |
+
# ======== ایجاد QR code لینک اعتبارسنجی آنلاین ========
|
| 81 |
+
validation_url = f"cert_id={cert_info['Certificate ID']}&code={verification_code}"
|
| 82 |
+
# ======== ایجاد QR code فقط با امضای دیجیتال ========
|
| 83 |
+
def create_qr_code(data, size=180):
|
| 84 |
+
qr = qrcode.QRCode(box_size=8, border=3)
|
| 85 |
+
qr.add_data(data)
|
| 86 |
+
qr.make(fit=True)
|
| 87 |
+
qr_img = qr.make_image(fill_color="#003366", back_color="white").convert("RGBA")
|
| 88 |
+
qr_img = qr_img.resize((size, size), Image.Resampling.LANCZOS)
|
| 89 |
+
return qr_img
|
| 90 |
+
|
| 91 |
+
qr_img = create_qr_code(digital_signature, size=180)
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
# ======== طراحی پسزمینه با گرادیانت ملایم ========
|
| 95 |
+
def draw_gradient(draw, width, height, start_color, end_color):
|
| 96 |
+
for i in range(height):
|
| 97 |
+
r = int(start_color[0] + (float(i) / height) * (end_color[0] - start_color[0]))
|
| 98 |
+
g = int(start_color[1] + (float(i) / height) * (end_color[1] - start_color[1]))
|
| 99 |
+
b = int(start_color[2] + (float(i) / height) * (end_color[2] - start_color[2]))
|
| 100 |
+
draw.line([(0, i), (width, i)], fill=(r, g, b))
|
| 101 |
+
|
| 102 |
+
# ======== رسم مهر رسمی پیشرفته ========
|
| 103 |
+
def create_official_seal(diameter=160):
|
| 104 |
+
seal = Image.new("RGBA", (diameter, diameter), (0, 0, 0, 0))
|
| 105 |
+
draw = ImageDraw.Draw(seal)
|
| 106 |
+
center = diameter // 2
|
| 107 |
+
|
| 108 |
+
# حلقه بیرونی با گرادیانت شعاعی قویتر
|
| 109 |
+
for i in range(10):
|
| 110 |
+
alpha = int(255 * (1 - i/10))
|
| 111 |
+
radius = center - i*5
|
| 112 |
+
color = (0, 51, 102, alpha)
|
| 113 |
+
draw.ellipse(
|
| 114 |
+
[(center - radius, center - radius), (center + radius, center + radius)],
|
| 115 |
+
outline=color,
|
| 116 |
+
width=3 if i % 2 == 0 else 2
|
| 117 |
+
)
|
| 118 |
+
|
| 119 |
+
# خطوط شعاعی تزئینی بیشتر و پرجزئیاتتر
|
| 120 |
+
num_rays = 36
|
| 121 |
+
outer_r = center - 15
|
| 122 |
+
inner_r = center - 50
|
| 123 |
+
for i in range(num_rays):
|
| 124 |
+
angle = 360 / num_rays * i
|
| 125 |
+
x1 = center + int(inner_r * math.cos(math.radians(angle)))
|
| 126 |
+
y1 = center + int(inner_r * math.sin(math.radians(angle)))
|
| 127 |
+
x2 = center + int(outer_r * math.cos(math.radians(angle)))
|
| 128 |
+
y2 = center + int(outer_r * math.sin(math.radians(angle)))
|
| 129 |
+
draw.line([(x1, y1), (x2, y2)], fill=(0, 51, 102, 200), width=2)
|
| 130 |
+
|
| 131 |
+
# قرار دادن لوگوی openai_seal.png وسط مهر اگر موجود باشد
|
| 132 |
+
try:
|
| 133 |
+
logo = Image.open("openai_seal.png").convert("RGBA")
|
| 134 |
+
max_logo_size = diameter - 100
|
| 135 |
+
logo.thumbnail((max_logo_size, max_logo_size), Image.Resampling.LANCZOS)
|
| 136 |
+
logo_pos = (center - logo.width // 2, center - logo.height // 2)
|
| 137 |
+
seal.paste(logo, logo_pos, logo)
|
| 138 |
+
except FileNotFoundError:
|
| 139 |
+
print("⚠️ فایل openai_seal.png پیدا نشد! مهر بدون لوگو ساخته شد.")
|
| 140 |
+
|
| 141 |
+
# متن مهر دایرهای قویتر و خواناتر
|
| 142 |
+
seal_text = "OFFICIAL OPENAI SEAL"
|
| 143 |
+
font_circle = load_font("timesbd.ttf", 18)
|
| 144 |
+
radius_text = center - 20
|
| 145 |
+
|
| 146 |
+
for i, char in enumerate(seal_text):
|
| 147 |
+
angle_deg = (360 / len(seal_text)) * i - 90
|
| 148 |
+
angle_rad = math.radians(angle_deg)
|
| 149 |
+
x = center + int(radius_text * math.cos(angle_rad))
|
| 150 |
+
y = center + int(radius_text * math.sin(angle_rad))
|
| 151 |
+
draw.text((x-8, y-8), char, font=font_circle, fill=(0, 51, 102, 255))
|
| 152 |
+
|
| 153 |
+
# سایه قویتر و واضحتر
|
| 154 |
+
seal = seal.filter(ImageFilter.GaussianBlur(radius=0.5))
|
| 155 |
+
|
| 156 |
+
return seal
|
| 157 |
+
|
| 158 |
+
official_seal = create_official_seal()
|
| 159 |
+
|
| 160 |
+
# ======== ایجاد تصویر گواهی ========
|
| 161 |
+
certificate = Image.new("RGBA", (CERT_WIDTH, CERT_HEIGHT), BACKGROUND_COLOR)
|
| 162 |
+
draw = ImageDraw.Draw(certificate)
|
| 163 |
+
|
| 164 |
+
draw_gradient(draw, CERT_WIDTH, CERT_HEIGHT, (255, 255, 250), (220, 230, 255))
|
| 165 |
+
|
| 166 |
+
for i, thickness in enumerate([6, 4, 2]):
|
| 167 |
+
color_val = 80 - i * 20
|
| 168 |
+
draw.rectangle(
|
| 169 |
+
[MARGIN - i*2, MARGIN - i*2, CERT_WIDTH - MARGIN + i*2, CERT_HEIGHT - MARGIN + i*2],
|
| 170 |
+
outline=(color_val, color_val, color_val)
|
| 171 |
+
)
|
| 172 |
+
|
| 173 |
+
# عنوان اصلی
|
| 174 |
+
title_text = "OpenAI – Certificate of Membership"
|
| 175 |
+
bbox = draw.textbbox((0, 0), title_text, font=font_title)
|
| 176 |
+
w = bbox[2] - bbox[0]
|
| 177 |
+
h = bbox[3] - bbox[1]
|
| 178 |
+
draw.text(((CERT_WIDTH - w) / 2, MARGIN + 10), title_text, fill=TITLE_COLOR, font=font_title)
|
| 179 |
+
|
| 180 |
+
line_y = MARGIN + h + 30
|
| 181 |
+
draw.line([(MARGIN + 10, line_y), (CERT_WIDTH - MARGIN - 10, line_y)], fill=(100, 100, 120), width=3)
|
| 182 |
+
|
| 183 |
+
info_x = MARGIN + 30
|
| 184 |
+
info_y = line_y + 20
|
| 185 |
+
line_spacing = 36
|
| 186 |
+
|
| 187 |
+
for key, val in cert_info.items():
|
| 188 |
+
text_line = f"{key}: {val}"
|
| 189 |
+
draw.text((info_x, info_y), text_line, font=font_text, fill=TEXT_COLOR)
|
| 190 |
+
info_y += line_spacing
|
| 191 |
+
|
| 192 |
+
verification_label = "Verification Code:"
|
| 193 |
+
verification_text = verification_code
|
| 194 |
+
info_y += 20
|
| 195 |
+
draw.text((info_x, info_y), verification_label, font=font_header, fill=TEXT_COLOR)
|
| 196 |
+
draw.text((info_x + 190, info_y), verification_text, font=font_header, fill=(0, 70, 120))
|
| 197 |
+
|
| 198 |
+
sig_lines = [digital_signature[i:i+60] for i in range(0, len(digital_signature), 60)]
|
| 199 |
+
sig_y = info_y + 40
|
| 200 |
+
for line in sig_lines:
|
| 201 |
+
draw.text((info_x, sig_y), line, font=font_small, fill=(100, 100, 120))
|
| 202 |
+
sig_y += 20
|
| 203 |
+
|
| 204 |
+
qr_pos = (CERT_WIDTH - qr_img.width - MARGIN - 20, CERT_HEIGHT - qr_img.height - MARGIN - 20)
|
| 205 |
+
seal_pos = (qr_pos[0], qr_pos[1] - official_seal.height - 15)
|
| 206 |
+
|
| 207 |
+
certificate.paste(official_seal, seal_pos, official_seal)
|
| 208 |
+
certificate.paste(qr_img, qr_pos, qr_img)
|
| 209 |
+
|
| 210 |
+
watermarks = [
|
| 211 |
+
"AUTHORIZED", "CONFIDENTIAL", "OFFICIAL_USE_ONLY", "SECURE",
|
| 212 |
+
"AUTHENTICATED", "NON-TRANSFERABLE", "GOVERNMENT APPROVED", "VERIFIED BY BLOCKCHAIN",
|
| 213 |
+
"HIGHLY CONFIDENTIAL", "DIGITAL SIGNED", "SECURE DOCUMENT", "UNIQUE IDENTIFIER",
|
| 214 |
+
"ENCRYPTED SEAL",
|
| 215 |
+
cert_info["Certificate ID"], verification_code,
|
| 216 |
+
"VALIDATED", "NO_COPY", "OPENAI"
|
| 217 |
+
]
|
| 218 |
+
|
| 219 |
+
for _ in range(128):
|
| 220 |
+
wm_text = random.choice(watermarks)
|
| 221 |
+
txt_img = Image.new("RGBA", (220, 20), (0, 0, 0, 0))
|
| 222 |
+
txt_draw = ImageDraw.Draw(txt_img)
|
| 223 |
+
txt_draw.text((0, 0), wm_text, font=font_small, fill=WATERMARK_COLOR)
|
| 224 |
+
angle = random.uniform(-25, 25)
|
| 225 |
+
txt_img = txt_img.rotate(angle, expand=1)
|
| 226 |
+
x = random.randint(MARGIN + 10, CERT_WIDTH - 230)
|
| 227 |
+
y = random.randint(MARGIN + 10, CERT_HEIGHT - 30)
|
| 228 |
+
certificate.paste(txt_img, (x, y), txt_img)
|
| 229 |
+
|
| 230 |
+
pixels = certificate.load()
|
| 231 |
+
for _ in range(NOISE_INTENSITY):
|
| 232 |
+
px = random.randint(0, CERT_WIDTH - 1)
|
| 233 |
+
py = random.randint(0, CERT_HEIGHT - 1)
|
| 234 |
+
r, g, b, a = pixels[px, py]
|
| 235 |
+
noise = random.randint(-5, 5)
|
| 236 |
+
r = max(0, min(255, r + noise))
|
| 237 |
+
g = max(0, min(255, g + noise))
|
| 238 |
+
b = max(0, min(255, b + noise))
|
| 239 |
+
pixels[px, py] = (r, g, b, a)
|
| 240 |
+
|
| 241 |
+
# ======== استگانوگرافی ساده برای درج کد امنیتی پنهان ========
|
| 242 |
+
def encode_message_in_pixels(img, message):
|
| 243 |
+
binary_message = ''.join(format(ord(i), '08b') for i in message)
|
| 244 |
+
pixels = img.load()
|
| 245 |
+
width, height = img.size
|
| 246 |
+
idx = 0
|
| 247 |
+
for y in range(height):
|
| 248 |
+
for x in range(width):
|
| 249 |
+
if idx >= len(binary_message):
|
| 250 |
+
return
|
| 251 |
+
r, g, b, a = pixels[x, y]
|
| 252 |
+
r = (r & ~1) | int(binary_message[idx])
|
| 253 |
+
pixels[x, y] = (r, g, b, a)
|
| 254 |
+
idx += 1
|
| 255 |
+
|
| 256 |
+
hidden_message = f"CertificateID:{cert_info['Certificate ID']};VerificationCode:{verification_code}"
|
| 257 |
+
encode_message_in_pixels(certificate, hidden_message)
|
| 258 |
+
|
| 259 |
+
output_file = f"OpenAI_Certificate_{cert_info['Certificate ID']}.png"
|
| 260 |
+
certificate.convert("RGB").save(output_file, quality=100)
|
| 261 |
+
print(f"✅ Realistic and highly secure certificate created: {output_file}")
|
cert/cert11.py
ADDED
|
@@ -0,0 +1,362 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from PIL import Image, ImageDraw, ImageFont, ImageFilter, ImageEnhance
|
| 2 |
+
import qrcode
|
| 3 |
+
import hashlib
|
| 4 |
+
import random
|
| 5 |
+
import math
|
| 6 |
+
import os
|
| 7 |
+
import base64
|
| 8 |
+
import datetime
|
| 9 |
+
from cryptography.hazmat.primitives.asymmetric import rsa, padding
|
| 10 |
+
from cryptography.hazmat.primitives import hashes, serialization
|
| 11 |
+
from cryptography.hazmat.backends import default_backend
|
| 12 |
+
|
| 13 |
+
# ======== Enhanced Configurations ========
|
| 14 |
+
CERT_WIDTH, CERT_HEIGHT = 1200, 900
|
| 15 |
+
MARGIN = 40
|
| 16 |
+
BACKGROUND_COLOR = (248, 246, 240)
|
| 17 |
+
BORDER_COLOR = (30, 30, 30)
|
| 18 |
+
TITLE_COLOR = (15, 15, 15)
|
| 19 |
+
TEXT_COLOR = (35, 35, 35)
|
| 20 |
+
WATERMARK_COLOR = (40, 40, 40, 20)
|
| 21 |
+
NOISE_INTENSITY = 4500
|
| 22 |
+
PAPER_TEXTURE_OPACITY = 0.15
|
| 23 |
+
HOLOGRAM_OPACITY = 0.35
|
| 24 |
+
|
| 25 |
+
# ======== Certificate Information ========
|
| 26 |
+
cert_info = {
|
| 27 |
+
"Name": "Yasin",
|
| 28 |
+
"Last Name": "Aryanfard",
|
| 29 |
+
"User ID": "YSNRFD",
|
| 30 |
+
"Membership Date": "April 1, 2023",
|
| 31 |
+
"Issued Date": datetime.datetime.now().strftime("%B %d, %Y"),
|
| 32 |
+
"Certificate ID": f"OPENAI-YSN-APR2023-CERT{random.randint(10000, 99999)}",
|
| 33 |
+
"Signed By": "ChatGPT-4o",
|
| 34 |
+
"Model ID": "GPT4O-REP-TRUST-2025",
|
| 35 |
+
"Issuer": "OpenAI, Inc."
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
# ======== RSA Key Generation ========
|
| 39 |
+
def generate_rsa_keys():
|
| 40 |
+
private_key = rsa.generate_private_key(
|
| 41 |
+
public_exponent=65537,
|
| 42 |
+
key_size=4096,
|
| 43 |
+
backend=default_backend()
|
| 44 |
+
)
|
| 45 |
+
public_key = private_key.public_key()
|
| 46 |
+
|
| 47 |
+
# Save public key for verification
|
| 48 |
+
pem = public_key.public_bytes(
|
| 49 |
+
encoding=serialization.Encoding.PEM,
|
| 50 |
+
format=serialization.PublicFormat.SubjectPublicKeyInfo
|
| 51 |
+
)
|
| 52 |
+
with open('certificate_public_key.pem', 'wb') as f:
|
| 53 |
+
f.write(pem)
|
| 54 |
+
|
| 55 |
+
return private_key, public_key
|
| 56 |
+
|
| 57 |
+
private_key, public_key = generate_rsa_keys()
|
| 58 |
+
|
| 59 |
+
# ======== Enhanced Font Loading ========
|
| 60 |
+
def load_font(name, size):
|
| 61 |
+
fallback_fonts = [
|
| 62 |
+
"arialbd.ttf", "timesbd.ttf", "courbd.ttf",
|
| 63 |
+
"DejaVuSans-Bold.ttf", "Georgia Bold.ttf"
|
| 64 |
+
]
|
| 65 |
+
for font_name in [name] + fallback_fonts:
|
| 66 |
+
try:
|
| 67 |
+
return ImageFont.truetype(font_name, size)
|
| 68 |
+
except:
|
| 69 |
+
continue
|
| 70 |
+
return ImageFont.load_default(size=size)
|
| 71 |
+
|
| 72 |
+
font_title = load_font("georgiaz.ttf", 42)
|
| 73 |
+
font_header = load_font("georgiab.ttf", 24)
|
| 74 |
+
font_text = load_font("georgia.ttf", 20)
|
| 75 |
+
font_small = load_font("cour.ttf", 16)
|
| 76 |
+
font_signature = load_font("BrushScriptStd.otf", 28)
|
| 77 |
+
|
| 78 |
+
# ======== Digital Signature Generation ========
|
| 79 |
+
data_string = "\n".join(f"{k}: {v}" for k, v in cert_info.items()).encode('utf-8')
|
| 80 |
+
|
| 81 |
+
signature = private_key.sign(
|
| 82 |
+
data_string,
|
| 83 |
+
padding.PSS(
|
| 84 |
+
mgf=padding.MGF1(hashes.SHA512()),
|
| 85 |
+
salt_length=padding.PSS.MAX_LENGTH
|
| 86 |
+
),
|
| 87 |
+
hashes.SHA512()
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
digital_signature = base64.b64encode(signature).decode('utf-8')
|
| 91 |
+
verification_code = f"VER-{hashlib.sha3_256(data_string).hexdigest()[:10].upper()}"
|
| 92 |
+
|
| 93 |
+
# ======== QR Code Generation ========
|
| 94 |
+
def create_qr_code(data, size=220):
|
| 95 |
+
qr = qrcode.QRCode(
|
| 96 |
+
version=7,
|
| 97 |
+
error_correction=qrcode.constants.ERROR_CORRECT_H,
|
| 98 |
+
box_size=10,
|
| 99 |
+
border=4
|
| 100 |
+
)
|
| 101 |
+
qr.add_data(data)
|
| 102 |
+
qr.make(fit=True)
|
| 103 |
+
|
| 104 |
+
qr_img = qr.make_image(
|
| 105 |
+
fill_color="#002855",
|
| 106 |
+
back_color="#F8F6F0"
|
| 107 |
+
).convert("RGBA")
|
| 108 |
+
|
| 109 |
+
# Add holographic effect
|
| 110 |
+
hologram = Image.new("RGBA", qr_img.size)
|
| 111 |
+
holo_draw = ImageDraw.Draw(hologram)
|
| 112 |
+
for i in range(0, qr_img.width, 5):
|
| 113 |
+
alpha = int(255 * (0.3 + 0.7 * abs(math.sin(i/50))))
|
| 114 |
+
holo_draw.line([(i, 0), (i, qr_img.height)],
|
| 115 |
+
fill=(100, 200, 255, alpha), width=3)
|
| 116 |
+
|
| 117 |
+
return Image.alpha_composite(qr_img, hologram)
|
| 118 |
+
|
| 119 |
+
qr_img = create_qr_code(f"{digital_signature}|{verification_code}")
|
| 120 |
+
|
| 121 |
+
# ======== Background Design ========
|
| 122 |
+
def create_certificate_base():
|
| 123 |
+
# Base with gradient
|
| 124 |
+
base = Image.new("RGB", (CERT_WIDTH, CERT_HEIGHT), BACKGROUND_COLOR)
|
| 125 |
+
draw = ImageDraw.Draw(base)
|
| 126 |
+
|
| 127 |
+
# Draw subtle grid
|
| 128 |
+
for i in range(0, CERT_WIDTH, 40):
|
| 129 |
+
alpha = 15 if i % 120 == 0 else 8
|
| 130 |
+
draw.line([(i, 0), (i, CERT_HEIGHT)], fill=(200, 200, 200, alpha), width=1)
|
| 131 |
+
for i in range(0, CERT_HEIGHT, 40):
|
| 132 |
+
alpha = 15 if i % 120 == 0 else 8
|
| 133 |
+
draw.line([(0, i), (CERT_WIDTH, i)], fill=(200, 200, 200, alpha), width=1)
|
| 134 |
+
|
| 135 |
+
# Add paper texture
|
| 136 |
+
texture = Image.new("RGBA", (CERT_WIDTH, CERT_HEIGHT), (0, 0, 0, 0))
|
| 137 |
+
tex_draw = ImageDraw.Draw(texture)
|
| 138 |
+
for _ in range(15000):
|
| 139 |
+
x, y = random.randint(0, CERT_WIDTH), random.randint(0, CERT_HEIGHT)
|
| 140 |
+
alpha = random.randint(10, 25)
|
| 141 |
+
size = random.randint(1, 3)
|
| 142 |
+
tex_draw.ellipse([(x, y), (x+size, y+size)],
|
| 143 |
+
fill=(150, 150, 150, alpha))
|
| 144 |
+
|
| 145 |
+
return Image.alpha_composite(base.convert("RGBA"), texture).convert("RGB")
|
| 146 |
+
|
| 147 |
+
# ======== Official Seal with OpenAI Logo ========
|
| 148 |
+
def create_official_seal(diameter=200):
|
| 149 |
+
seal = Image.new("RGBA", (diameter, diameter), (0, 0, 0, 0))
|
| 150 |
+
draw = ImageDraw.Draw(seal)
|
| 151 |
+
center = diameter // 2
|
| 152 |
+
|
| 153 |
+
# Complex seal pattern
|
| 154 |
+
for i in range(1, 15):
|
| 155 |
+
alpha = int(255 * (1 - i/15))
|
| 156 |
+
radius = center - i*3
|
| 157 |
+
color = (0, 48, 92, alpha)
|
| 158 |
+
draw.ellipse(
|
| 159 |
+
[(center - radius, center - radius),
|
| 160 |
+
(center + radius, center + radius)],
|
| 161 |
+
outline=color,
|
| 162 |
+
width=2
|
| 163 |
+
)
|
| 164 |
+
|
| 165 |
+
# Ornate details
|
| 166 |
+
num_points = 24
|
| 167 |
+
for i in range(num_points):
|
| 168 |
+
angle = math.radians(i * 360/num_points)
|
| 169 |
+
x1 = center + int((diameter*0.42) * math.cos(angle))
|
| 170 |
+
y1 = center + int((diameter*0.42) * math.sin(angle))
|
| 171 |
+
x2 = center + int((diameter*0.47) * math.cos(angle))
|
| 172 |
+
y2 = center + int((diameter*0.47) * math.sin(angle))
|
| 173 |
+
draw.line([(x1, y1), (x2, y2)], fill=(0, 48, 92, 220), width=3)
|
| 174 |
+
|
| 175 |
+
# Add holographic effect
|
| 176 |
+
for i in range(0, diameter, 4):
|
| 177 |
+
alpha = int(180 * (0.4 + 0.6 * abs(math.sin(i/20))))
|
| 178 |
+
draw.arc(
|
| 179 |
+
[(i//4, i//4), (diameter-i//4, diameter-i//4)],
|
| 180 |
+
start=0,
|
| 181 |
+
end=360,
|
| 182 |
+
fill=(100, 200, 255, alpha),
|
| 183 |
+
width=2
|
| 184 |
+
)
|
| 185 |
+
|
| 186 |
+
# Seal text
|
| 187 |
+
text = "OFFICIAL SEAL • VERIFIED • DIGITAL"
|
| 188 |
+
font_seal = load_font("timesbd.ttf", 14)
|
| 189 |
+
for i, char in enumerate(text):
|
| 190 |
+
angle = math.radians(i * 360/len(text) - 90)
|
| 191 |
+
x = center + int(center*0.65 * math.cos(angle)) - 5
|
| 192 |
+
y = center + int(center*0.65 * math.sin(angle)) - 5
|
| 193 |
+
draw.text((x, y), char, font=font_seal, fill=(0, 48, 92, 255))
|
| 194 |
+
|
| 195 |
+
# Add OpenAI logo to center of seal
|
| 196 |
+
try:
|
| 197 |
+
logo = Image.open("openai_seal.png").convert("RGBA")
|
| 198 |
+
logo_size = diameter // 2 # Size relative to seal diameter
|
| 199 |
+
logo.thumbnail((logo_size, logo_size), Image.LANCZOS)
|
| 200 |
+
logo_pos = (center - logo.width // 2, center - logo.height // 2)
|
| 201 |
+
|
| 202 |
+
# Create glow effect around logo
|
| 203 |
+
glow = Image.new("RGBA", (logo.width+10, logo.height+10), (0,0,0,0))
|
| 204 |
+
glow_draw = ImageDraw.Draw(glow)
|
| 205 |
+
glow_draw.ellipse([(0,0), (logo.width+10, logo.height+10)],
|
| 206 |
+
fill=(100, 200, 255, 60))
|
| 207 |
+
glow = glow.filter(ImageFilter.GaussianBlur(radius=5))
|
| 208 |
+
|
| 209 |
+
# Paste glow then logo
|
| 210 |
+
seal.paste(glow, (logo_pos[0]-5, logo_pos[1]-5), glow)
|
| 211 |
+
seal.paste(logo, logo_pos, logo)
|
| 212 |
+
except Exception as e:
|
| 213 |
+
print(f"⚠️ Could not load openai_seal.png: {e}")
|
| 214 |
+
# Draw simple OpenAI-inspired logo as fallback
|
| 215 |
+
draw.regular_polygon((center, center, diameter//4),
|
| 216 |
+
n_sides=6,
|
| 217 |
+
fill=(0, 48, 92, 180))
|
| 218 |
+
|
| 219 |
+
return seal
|
| 220 |
+
|
| 221 |
+
# ======== Main Certificate Creation ========
|
| 222 |
+
certificate = create_certificate_base().convert("RGBA")
|
| 223 |
+
draw = ImageDraw.Draw(certificate)
|
| 224 |
+
|
| 225 |
+
# Border design
|
| 226 |
+
for i, thickness in enumerate([8, 5, 3, 1]):
|
| 227 |
+
offset = MARGIN - i*3
|
| 228 |
+
draw.rectangle(
|
| 229 |
+
[offset, offset, CERT_WIDTH - offset, CERT_HEIGHT - offset],
|
| 230 |
+
outline=(30, 30, 30),
|
| 231 |
+
width=thickness
|
| 232 |
+
)
|
| 233 |
+
|
| 234 |
+
# Title section
|
| 235 |
+
title = "CERTIFICATE OF AUTHENTICITY"
|
| 236 |
+
bbox = draw.textbbox((0, 0), title, font=font_title)
|
| 237 |
+
draw.text(
|
| 238 |
+
((CERT_WIDTH - bbox[2])/2, MARGIN + 30),
|
| 239 |
+
title,
|
| 240 |
+
fill=TITLE_COLOR,
|
| 241 |
+
font=font_title
|
| 242 |
+
)
|
| 243 |
+
|
| 244 |
+
subtitle = "Issued by OpenAI for Distinguished Contribution"
|
| 245 |
+
font_subtitle = load_font("georgiai.ttf", 22)
|
| 246 |
+
bbox = draw.textbbox((0, 0), subtitle, font=font_subtitle)
|
| 247 |
+
draw.text(
|
| 248 |
+
((CERT_WIDTH - bbox[2])/2, MARGIN + 90),
|
| 249 |
+
subtitle,
|
| 250 |
+
fill=(70, 70, 70),
|
| 251 |
+
font=font_subtitle
|
| 252 |
+
)
|
| 253 |
+
|
| 254 |
+
# Decorative elements
|
| 255 |
+
draw.line(
|
| 256 |
+
[(MARGIN+50, MARGIN+150), (CERT_WIDTH-MARGIN-50, MARGIN+150)],
|
| 257 |
+
fill=(150, 150, 150),
|
| 258 |
+
width=2
|
| 259 |
+
)
|
| 260 |
+
|
| 261 |
+
# Certificate information
|
| 262 |
+
info_y = MARGIN + 180
|
| 263 |
+
for key, value in cert_info.items():
|
| 264 |
+
draw.text(
|
| 265 |
+
(MARGIN+80, info_y),
|
| 266 |
+
f"{key}:",
|
| 267 |
+
font=font_header,
|
| 268 |
+
fill=(80, 80, 80))
|
| 269 |
+
draw.text(
|
| 270 |
+
(MARGIN+300, info_y),
|
| 271 |
+
value,
|
| 272 |
+
font=font_text,
|
| 273 |
+
fill=TEXT_COLOR)
|
| 274 |
+
info_y += 50
|
| 275 |
+
|
| 276 |
+
# Security section
|
| 277 |
+
info_y += 30
|
| 278 |
+
draw.text(
|
| 279 |
+
(MARGIN+80, info_y),
|
| 280 |
+
"Digital Verification:",
|
| 281 |
+
font=font_header,
|
| 282 |
+
fill=(80, 80, 80))
|
| 283 |
+
draw.text(
|
| 284 |
+
(MARGIN+300, info_y),
|
| 285 |
+
verification_code,
|
| 286 |
+
font=font_text,
|
| 287 |
+
fill=(0, 70, 120))
|
| 288 |
+
info_y += 40
|
| 289 |
+
|
| 290 |
+
# Digital signature block
|
| 291 |
+
sig_text = "Cryptographic Signature:"
|
| 292 |
+
draw.text((MARGIN+80, info_y), sig_text, font=font_small, fill=(100, 100, 100))
|
| 293 |
+
info_y += 25
|
| 294 |
+
signature_lines = [digital_signature[i:i+64] for i in range(0, len(digital_signature), 64)]
|
| 295 |
+
for line in signature_lines[:4]:
|
| 296 |
+
draw.text((MARGIN+100, info_y), line, font=font_small, fill=(70, 70, 70))
|
| 297 |
+
info_y += 22
|
| 298 |
+
|
| 299 |
+
# Official elements with OpenAI logo
|
| 300 |
+
seal = create_official_seal()
|
| 301 |
+
certificate.paste(
|
| 302 |
+
seal,
|
| 303 |
+
(CERT_WIDTH - MARGIN - seal.width - 50, MARGIN + 180),
|
| 304 |
+
seal
|
| 305 |
+
)
|
| 306 |
+
|
| 307 |
+
qr_position = (CERT_WIDTH - MARGIN - qr_img.width, CERT_HEIGHT - MARGIN - qr_img.height - 50)
|
| 308 |
+
certificate.paste(qr_img, qr_position, qr_img)
|
| 309 |
+
|
| 310 |
+
# Signature area
|
| 311 |
+
signature_y = CERT_HEIGHT - MARGIN - 150
|
| 312 |
+
draw.line(
|
| 313 |
+
[(MARGIN+100, signature_y), (MARGIN+400, signature_y)],
|
| 314 |
+
fill=(30, 30, 30),
|
| 315 |
+
width=2
|
| 316 |
+
)
|
| 317 |
+
draw.text(
|
| 318 |
+
(MARGIN+100, signature_y + 10),
|
| 319 |
+
"Dr. Sam Altman, Chief Executive Officer",
|
| 320 |
+
font=font_small,
|
| 321 |
+
fill=(60, 60, 60))
|
| 322 |
+
draw.text(
|
| 323 |
+
(MARGIN+100, signature_y - 40),
|
| 324 |
+
"Authorized Signature",
|
| 325 |
+
font=font_signature,
|
| 326 |
+
fill=(30, 30, 30))
|
| 327 |
+
|
| 328 |
+
# Security watermarks
|
| 329 |
+
watermarks = [
|
| 330 |
+
"SECURE DOCUMENT", "OFFICIAL RECORD", "DO NOT DUPLICATE",
|
| 331 |
+
"VERIFIED", cert_info['Certificate ID'], verification_code,
|
| 332 |
+
"PROTECTED CONTENT", "DIGITALLY SIGNED", "OPENAI AUTHENTICATED"
|
| 333 |
+
]
|
| 334 |
+
|
| 335 |
+
for _ in range(150):
|
| 336 |
+
wm_text = random.choice(watermarks)
|
| 337 |
+
txt_img = Image.new("RGBA", (400, 40), (0, 0, 0, 0))
|
| 338 |
+
txt_draw = ImageDraw.Draw(txt_img)
|
| 339 |
+
|
| 340 |
+
alpha = random.randint(15, 30)
|
| 341 |
+
txt_draw.text(
|
| 342 |
+
(10, 10),
|
| 343 |
+
wm_text,
|
| 344 |
+
font=font_small,
|
| 345 |
+
fill=(40, 40, 40, alpha))
|
| 346 |
+
|
| 347 |
+
angle = random.uniform(-45, 45)
|
| 348 |
+
txt_img = txt_img.rotate(angle, expand=True, resample=Image.BICUBIC)
|
| 349 |
+
|
| 350 |
+
x = random.randint(0, CERT_WIDTH - txt_img.width)
|
| 351 |
+
y = random.randint(0, CERT_HEIGHT - txt_img.height)
|
| 352 |
+
certificate.paste(txt_img, (x, y), txt_img)
|
| 353 |
+
|
| 354 |
+
# Final touches
|
| 355 |
+
certificate = certificate.filter(ImageFilter.SMOOTH)
|
| 356 |
+
certificate = certificate.filter(ImageFilter.SHARPEN)
|
| 357 |
+
|
| 358 |
+
# Save certificate
|
| 359 |
+
output_filename = f"OpenAI_Certificate_{cert_info['Certificate ID']}.png"
|
| 360 |
+
certificate.save(output_filename, dpi=(300, 300), quality=100)
|
| 361 |
+
print(f"✅ Professional certificate created: {output_filename}")
|
| 362 |
+
print(f"🔑 Public key saved to: certificate_public_key.pem")
|
cert/cert12.py
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from PIL import Image, ImageDraw, ImageFont, ImageFilter, ImageEnhance
|
| 2 |
+
import qrcode
|
| 3 |
+
import hashlib
|
| 4 |
+
import random
|
| 5 |
+
import math
|
| 6 |
+
import os
|
| 7 |
+
import base64
|
| 8 |
+
import datetime
|
| 9 |
+
from cryptography.hazmat.primitives.asymmetric import rsa, padding
|
| 10 |
+
from cryptography.hazmat.primitives import hashes, serialization
|
| 11 |
+
from cryptography.hazmat.backends import default_backend
|
| 12 |
+
|
| 13 |
+
# ======== Enhanced Configurations ========
|
| 14 |
+
CERT_WIDTH, CERT_HEIGHT = 1200, 900
|
| 15 |
+
MARGIN = 40
|
| 16 |
+
BACKGROUND_COLOR = (248, 246, 240)
|
| 17 |
+
BORDER_COLOR = (30, 30, 30)
|
| 18 |
+
TITLE_COLOR = (15, 15, 15)
|
| 19 |
+
TEXT_COLOR = (35, 35, 35)
|
| 20 |
+
WATERMARK_COLOR = (40, 40, 40, 20)
|
| 21 |
+
NOISE_INTENSITY = 4500
|
| 22 |
+
PAPER_TEXTURE_OPACITY = 0.15
|
| 23 |
+
HOLOGRAM_OPACITY = 0.35
|
| 24 |
+
|
| 25 |
+
# ======== Certificate Information ========
|
| 26 |
+
cert_info = {
|
| 27 |
+
"Name": "Yasin",
|
| 28 |
+
"Last Name": "Aryanfard",
|
| 29 |
+
"User ID": "YSNRFD",
|
| 30 |
+
"Membership Date": "April 1, 2023",
|
| 31 |
+
"Issued Date": datetime.datetime.now().strftime("%B %d, %Y"),
|
| 32 |
+
"Certificate ID": f"OPENAI-YSN-APR2023-CERT{random.randint(10000, 99999)}",
|
| 33 |
+
"Signed By": "ChatGPT-4o",
|
| 34 |
+
"Model ID": "GPT4O-REP-TRUST-2025",
|
| 35 |
+
"Issuer": "OpenAI, Inc."
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
# ======== RSA Key Generation ========
|
| 39 |
+
def generate_rsa_keys():
|
| 40 |
+
private_key = rsa.generate_private_key(
|
| 41 |
+
public_exponent=65537,
|
| 42 |
+
key_size=4096,
|
| 43 |
+
backend=default_backend()
|
| 44 |
+
)
|
| 45 |
+
public_key = private_key.public_key()
|
| 46 |
+
|
| 47 |
+
# Save public key for verification
|
| 48 |
+
pem = public_key.public_bytes(
|
| 49 |
+
encoding=serialization.Encoding.PEM,
|
| 50 |
+
format=serialization.PublicFormat.SubjectPublicKeyInfo
|
| 51 |
+
)
|
| 52 |
+
with open('certificate_public_key.pem', 'wb') as f:
|
| 53 |
+
f.write(pem)
|
| 54 |
+
|
| 55 |
+
return private_key, public_key
|
| 56 |
+
|
| 57 |
+
private_key, public_key = generate_rsa_keys()
|
| 58 |
+
|
| 59 |
+
# ======== Enhanced Font Loading ========
|
| 60 |
+
def load_font(name, size):
|
| 61 |
+
fallback_fonts = [
|
| 62 |
+
"arial.ttf", "arialbd.ttf", "times.ttf", "timesbd.ttf",
|
| 63 |
+
"cour.ttf", "courbd.ttf", "DejaVuSans.ttf", "DejaVuSans-Bold.ttf"
|
| 64 |
+
]
|
| 65 |
+
try:
|
| 66 |
+
# اول سعی میکنیم فونت درخواستی را بارگذاری کنیم
|
| 67 |
+
return ImageFont.truetype(name, size)
|
| 68 |
+
except IOError:
|
| 69 |
+
# سپس فونتهای فالبک را امتحان میکنیم
|
| 70 |
+
for font_name in fallback_fonts:
|
| 71 |
+
try:
|
| 72 |
+
return ImageFont.truetype(font_name, size)
|
| 73 |
+
except IOError:
|
| 74 |
+
continue
|
| 75 |
+
# در نهایت از فونت پیشفرض سیستم استفاده میکنیم
|
| 76 |
+
return ImageFont.load_default()
|
| 77 |
+
|
| 78 |
+
font_title = load_font("georgiaz.ttf", 42)
|
| 79 |
+
font_header = load_font("georgiab.ttf", 24)
|
| 80 |
+
font_text = load_font("georgia.ttf", 20)
|
| 81 |
+
font_small = load_font("cour.ttf", 16)
|
| 82 |
+
font_signature = load_font("BrushScriptStd.otf", 28)
|
| 83 |
+
|
| 84 |
+
# ======== Digital Signature Generation ========
|
| 85 |
+
data_string = "\n".join(f"{k}: {v}" for k, v in cert_info.items()).encode('utf-8')
|
| 86 |
+
|
| 87 |
+
signature = private_key.sign(
|
| 88 |
+
data_string,
|
| 89 |
+
padding.PSS(
|
| 90 |
+
mgf=padding.MGF1(hashes.SHA512()),
|
| 91 |
+
salt_length=padding.PSS.MAX_LENGTH
|
| 92 |
+
),
|
| 93 |
+
hashes.SHA512()
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
digital_signature = base64.b64encode(signature).decode('utf-8')
|
| 97 |
+
verification_code = f"VER-{hashlib.sha3_256(data_string).hexdigest()[:10].upper()}"
|
| 98 |
+
|
| 99 |
+
# ======== QR Code Generation ========
|
| 100 |
+
def create_qr_code(data, size=220):
|
| 101 |
+
qr = qrcode.QRCode(
|
| 102 |
+
version=7,
|
| 103 |
+
error_correction=qrcode.constants.ERROR_CORRECT_H,
|
| 104 |
+
box_size=10,
|
| 105 |
+
border=4
|
| 106 |
+
)
|
| 107 |
+
qr.add_data(data)
|
| 108 |
+
qr.make(fit=True)
|
| 109 |
+
|
| 110 |
+
qr_img = qr.make_image(
|
| 111 |
+
fill_color="#002855",
|
| 112 |
+
back_color="#F8F6F0"
|
| 113 |
+
).convert("RGBA")
|
| 114 |
+
|
| 115 |
+
# Add holographic effect
|
| 116 |
+
hologram = Image.new("RGBA", qr_img.size)
|
| 117 |
+
holo_draw = ImageDraw.Draw(hologram)
|
| 118 |
+
for i in range(0, qr_img.width, 5):
|
| 119 |
+
alpha = int(255 * (0.3 + 0.7 * abs(math.sin(i/50))))
|
| 120 |
+
holo_draw.line([(i, 0), (i, qr_img.height)],
|
| 121 |
+
fill=(100, 200, 255, alpha), width=3)
|
| 122 |
+
|
| 123 |
+
return Image.alpha_composite(qr_img, hologram)
|
| 124 |
+
|
| 125 |
+
qr_img = create_qr_code(f"{digital_signature}|{verification_code}")
|
| 126 |
+
|
| 127 |
+
# ======== Background Design ========
|
| 128 |
+
def create_certificate_base():
|
| 129 |
+
# Base with gradient
|
| 130 |
+
base = Image.new("RGB", (CERT_WIDTH, CERT_HEIGHT), BACKGROUND_COLOR)
|
| 131 |
+
draw = ImageDraw.Draw(base)
|
| 132 |
+
|
| 133 |
+
# Draw subtle grid
|
| 134 |
+
for i in range(0, CERT_WIDTH, 40):
|
| 135 |
+
alpha = 15 if i % 120 == 0 else 8
|
| 136 |
+
draw.line([(i, 0), (i, CERT_HEIGHT)], fill=(200, 200, 200, alpha), width=1)
|
| 137 |
+
for i in range(0, CERT_HEIGHT, 40):
|
| 138 |
+
alpha = 15 if i % 120 == 0 else 8
|
| 139 |
+
draw.line([(0, i), (CERT_WIDTH, i)], fill=(200, 200, 200, alpha), width=1)
|
| 140 |
+
|
| 141 |
+
# Add paper texture
|
| 142 |
+
texture = Image.new("RGBA", (CERT_WIDTH, CERT_HEIGHT), (0, 0, 0, 0))
|
| 143 |
+
tex_draw = ImageDraw.Draw(texture)
|
| 144 |
+
for _ in range(15000):
|
| 145 |
+
x, y = random.randint(0, CERT_WIDTH), random.randint(0, CERT_HEIGHT)
|
| 146 |
+
alpha = random.randint(10, 25)
|
| 147 |
+
size = random.randint(1, 3)
|
| 148 |
+
tex_draw.ellipse([(x, y), (x+size, y+size)],
|
| 149 |
+
fill=(150, 150, 150, alpha))
|
| 150 |
+
|
| 151 |
+
return Image.alpha_composite(base.convert("RGBA"), texture).convert("RGB")
|
| 152 |
+
|
| 153 |
+
# ======== Official Seal with OpenAI Logo ========
|
| 154 |
+
def create_official_seal(diameter=200):
|
| 155 |
+
seal = Image.new("RGBA", (diameter, diameter), (0, 0, 0, 0))
|
| 156 |
+
draw = ImageDraw.Draw(seal)
|
| 157 |
+
center = diameter // 2
|
| 158 |
+
|
| 159 |
+
# Complex seal pattern
|
| 160 |
+
for i in range(1, 15):
|
| 161 |
+
alpha = int(255 * (1 - i/15))
|
| 162 |
+
radius = center - i*3
|
| 163 |
+
color = (0, 48, 92, alpha)
|
| 164 |
+
draw.ellipse(
|
| 165 |
+
[(center - radius, center - radius),
|
| 166 |
+
(center + radius, center + radius)],
|
| 167 |
+
outline=color,
|
| 168 |
+
width=2
|
| 169 |
+
)
|
| 170 |
+
|
| 171 |
+
# Ornate details
|
| 172 |
+
num_points = 24
|
| 173 |
+
for i in range(num_points):
|
| 174 |
+
angle = math.radians(i * 360/num_points)
|
| 175 |
+
x1 = center + int((diameter*0.42) * math.cos(angle))
|
| 176 |
+
y1 = center + int((diameter*0.42) * math.sin(angle))
|
| 177 |
+
x2 = center + int((diameter*0.47) * math.cos(angle))
|
| 178 |
+
y2 = center + int((diameter*0.47) * math.sin(angle))
|
| 179 |
+
draw.line([(x1, y1), (x2, y2)], fill=(0, 48, 92, 220), width=3)
|
| 180 |
+
|
| 181 |
+
# Add holographic effect
|
| 182 |
+
for i in range(0, diameter, 4):
|
| 183 |
+
alpha = int(180 * (0.4 + 0.6 * abs(math.sin(i/20))))
|
| 184 |
+
draw.arc(
|
| 185 |
+
[(i//4, i//4), (diameter-i//4, diameter-i//4)],
|
| 186 |
+
start=0,
|
| 187 |
+
end=360,
|
| 188 |
+
fill=(100, 200, 255, alpha),
|
| 189 |
+
width=2
|
| 190 |
+
)
|
| 191 |
+
|
| 192 |
+
# Seal text
|
| 193 |
+
text = "OFFICIAL SEAL • VERIFIED • DIGITAL"
|
| 194 |
+
font_seal = load_font("timesbd.ttf", 14)
|
| 195 |
+
for i, char in enumerate(text):
|
| 196 |
+
angle = math.radians(i * 360/len(text) - 90)
|
| 197 |
+
x = center + int(center*0.65 * math.cos(angle)) - 5
|
| 198 |
+
y = center + int(center*0.65 * math.sin(angle)) - 5
|
| 199 |
+
draw.text((x, y), char, font=font_seal, fill=(0, 48, 92, 255))
|
| 200 |
+
|
| 201 |
+
# Add OpenAI logo to center of seal
|
| 202 |
+
try:
|
| 203 |
+
logo = Image.open("openai_seal.png").convert("RGBA")
|
| 204 |
+
logo_size = diameter // 2 # Size relative to seal diameter
|
| 205 |
+
logo.thumbnail((logo_size, logo_size), Image.LANCZOS)
|
| 206 |
+
logo_pos = (center - logo.width // 2, center - logo.height // 2)
|
| 207 |
+
|
| 208 |
+
# Create glow effect around logo
|
| 209 |
+
glow = Image.new("RGBA", (logo.width+10, logo.height+10), (0,0,0,0))
|
| 210 |
+
glow_draw = ImageDraw.Draw(glow)
|
| 211 |
+
glow_draw.ellipse([(0,0), (logo.width+10, logo.height+10)],
|
| 212 |
+
fill=(100, 200, 255, 60))
|
| 213 |
+
glow = glow.filter(ImageFilter.GaussianBlur(radius=5))
|
| 214 |
+
|
| 215 |
+
# Paste glow then logo
|
| 216 |
+
seal.paste(glow, (logo_pos[0]-5, logo_pos[1]-5), glow)
|
| 217 |
+
seal.paste(logo, logo_pos, logo)
|
| 218 |
+
except Exception as e:
|
| 219 |
+
print(f"⚠️ Could not load openai_seal.png: {e}")
|
| 220 |
+
# Draw simple OpenAI-inspired logo as fallback
|
| 221 |
+
draw.regular_polygon((center, center, diameter//4),
|
| 222 |
+
n_sides=6,
|
| 223 |
+
fill=(0, 48, 92, 180))
|
| 224 |
+
|
| 225 |
+
return seal
|
| 226 |
+
|
| 227 |
+
# ======== Main Certificate Creation ========
|
| 228 |
+
certificate = create_certificate_base().convert("RGBA")
|
| 229 |
+
draw = ImageDraw.Draw(certificate)
|
| 230 |
+
|
| 231 |
+
# Border design
|
| 232 |
+
for i, thickness in enumerate([8, 5, 3, 1]):
|
| 233 |
+
offset = MARGIN - i*3
|
| 234 |
+
draw.rectangle(
|
| 235 |
+
[offset, offset, CERT_WIDTH - offset, CERT_HEIGHT - offset],
|
| 236 |
+
outline=(30, 30, 30),
|
| 237 |
+
width=thickness
|
| 238 |
+
)
|
| 239 |
+
|
| 240 |
+
# Title section
|
| 241 |
+
title = "CERTIFICATE OF AUTHENTICITY"
|
| 242 |
+
bbox = draw.textbbox((0, 0), title, font=font_title)
|
| 243 |
+
draw.text(
|
| 244 |
+
((CERT_WIDTH - bbox[2])/2, MARGIN + 30),
|
| 245 |
+
title,
|
| 246 |
+
fill=TITLE_COLOR,
|
| 247 |
+
font=font_title
|
| 248 |
+
)
|
| 249 |
+
|
| 250 |
+
subtitle = "Issued by OpenAI for Distinguished Contribution"
|
| 251 |
+
font_subtitle = load_font("georgiai.ttf", 22)
|
| 252 |
+
bbox = draw.textbbox((0, 0), subtitle, font=font_subtitle)
|
| 253 |
+
draw.text(
|
| 254 |
+
((CERT_WIDTH - bbox[2])/2, MARGIN + 90),
|
| 255 |
+
subtitle,
|
| 256 |
+
fill=(70, 70, 70),
|
| 257 |
+
font=font_subtitle
|
| 258 |
+
)
|
| 259 |
+
|
| 260 |
+
# Decorative elements
|
| 261 |
+
draw.line(
|
| 262 |
+
[(MARGIN+50, MARGIN+150), (CERT_WIDTH-MARGIN-50, MARGIN+150)],
|
| 263 |
+
fill=(150, 150, 150),
|
| 264 |
+
width=2
|
| 265 |
+
)
|
| 266 |
+
|
| 267 |
+
# Certificate information
|
| 268 |
+
info_y = MARGIN + 180
|
| 269 |
+
for key, value in cert_info.items():
|
| 270 |
+
draw.text(
|
| 271 |
+
(MARGIN+80, info_y),
|
| 272 |
+
f"{key}:",
|
| 273 |
+
font=font_header,
|
| 274 |
+
fill=(80, 80, 80))
|
| 275 |
+
draw.text(
|
| 276 |
+
(MARGIN+300, info_y),
|
| 277 |
+
value,
|
| 278 |
+
font=font_text,
|
| 279 |
+
fill=TEXT_COLOR)
|
| 280 |
+
info_y += 50
|
| 281 |
+
|
| 282 |
+
# Security section
|
| 283 |
+
info_y += 30
|
| 284 |
+
draw.text(
|
| 285 |
+
(MARGIN+80, info_y),
|
| 286 |
+
"Digital Verification:",
|
| 287 |
+
font=font_header,
|
| 288 |
+
fill=(80, 80, 80))
|
| 289 |
+
draw.text(
|
| 290 |
+
(MARGIN+300, info_y),
|
| 291 |
+
verification_code,
|
| 292 |
+
font=font_text,
|
| 293 |
+
fill=(0, 70, 120))
|
| 294 |
+
info_y += 40
|
| 295 |
+
|
| 296 |
+
# Digital signature block
|
| 297 |
+
sig_text = "Cryptographic Signature:"
|
| 298 |
+
draw.text((MARGIN+80, info_y), sig_text, font=font_small, fill=(100, 100, 100))
|
| 299 |
+
info_y += 25
|
| 300 |
+
signature_lines = [digital_signature[i:i+64] for i in range(0, len(digital_signature), 64)]
|
| 301 |
+
for line in signature_lines[:4]:
|
| 302 |
+
draw.text((MARGIN+100, info_y), line, font=font_small, fill=(70, 70, 70))
|
| 303 |
+
info_y += 22
|
| 304 |
+
|
| 305 |
+
# Official elements with OpenAI logo
|
| 306 |
+
seal = create_official_seal()
|
| 307 |
+
certificate.paste(
|
| 308 |
+
seal,
|
| 309 |
+
(CERT_WIDTH - MARGIN - seal.width - 50, MARGIN + 180),
|
| 310 |
+
seal
|
| 311 |
+
)
|
| 312 |
+
|
| 313 |
+
qr_position = (CERT_WIDTH - MARGIN - qr_img.width, CERT_HEIGHT - MARGIN - qr_img.height - 50)
|
| 314 |
+
certificate.paste(qr_img, qr_position, qr_img)
|
| 315 |
+
|
| 316 |
+
# Signature area
|
| 317 |
+
signature_y = CERT_HEIGHT - MARGIN - 150
|
| 318 |
+
draw.line(
|
| 319 |
+
[(MARGIN+100, signature_y), (MARGIN+400, signature_y)],
|
| 320 |
+
fill=(30, 30, 30),
|
| 321 |
+
width=2
|
| 322 |
+
)
|
| 323 |
+
draw.text(
|
| 324 |
+
(MARGIN+100, signature_y + 10),
|
| 325 |
+
"Dr. Sam Altman, Chief Executive Officer",
|
| 326 |
+
font=font_small,
|
| 327 |
+
fill=(60, 60, 60))
|
| 328 |
+
draw.text(
|
| 329 |
+
(MARGIN+100, signature_y - 40),
|
| 330 |
+
"Authorized Signature",
|
| 331 |
+
font=font_signature,
|
| 332 |
+
fill=(30, 30, 30))
|
| 333 |
+
|
| 334 |
+
# Security watermarks
|
| 335 |
+
watermarks = [
|
| 336 |
+
"SECURE DOCUMENT", "OFFICIAL RECORD", "DO NOT DUPLICATE",
|
| 337 |
+
"VERIFIED", cert_info['Certificate ID'], verification_code,
|
| 338 |
+
"PROTECTED CONTENT", "DIGITALLY SIGNED", "OPENAI AUTHENTICATED"
|
| 339 |
+
]
|
| 340 |
+
|
| 341 |
+
for _ in range(150):
|
| 342 |
+
wm_text = random.choice(watermarks)
|
| 343 |
+
txt_img = Image.new("RGBA", (400, 40), (0, 0, 0, 0))
|
| 344 |
+
txt_draw = ImageDraw.Draw(txt_img)
|
| 345 |
+
|
| 346 |
+
alpha = random.randint(15, 30)
|
| 347 |
+
txt_draw.text(
|
| 348 |
+
(10, 10),
|
| 349 |
+
wm_text,
|
| 350 |
+
font=font_small,
|
| 351 |
+
fill=(40, 40, 40, alpha))
|
| 352 |
+
|
| 353 |
+
angle = random.uniform(-45, 45)
|
| 354 |
+
txt_img = txt_img.rotate(angle, expand=True, resample=Image.BICUBIC)
|
| 355 |
+
|
| 356 |
+
x = random.randint(0, CERT_WIDTH - txt_img.width)
|
| 357 |
+
y = random.randint(0, CERT_HEIGHT - txt_img.height)
|
| 358 |
+
certificate.paste(txt_img, (x, y), txt_img)
|
| 359 |
+
|
| 360 |
+
# Final touches
|
| 361 |
+
certificate = certificate.filter(ImageFilter.SMOOTH)
|
| 362 |
+
certificate = certificate.filter(ImageFilter.SHARPEN)
|
| 363 |
+
|
| 364 |
+
# Save certificate
|
| 365 |
+
output_filename = f"OpenAI_Certificate_{cert_info['Certificate ID']}.png"
|
| 366 |
+
certificate.save(output_filename, dpi=(300, 300), quality=100)
|
| 367 |
+
print(f"✅ Professional certificate created: {output_filename}")
|
| 368 |
+
print(f"🔑 Public key saved to: certificate_public_key.pem")
|
cert/cert13.py
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from PIL import Image, ImageDraw, ImageFont, ImageFilter
|
| 2 |
+
import qrcode
|
| 3 |
+
import hashlib
|
| 4 |
+
import random
|
| 5 |
+
import math
|
| 6 |
+
import os
|
| 7 |
+
import base64
|
| 8 |
+
|
| 9 |
+
from cryptography.hazmat.primitives.asymmetric import rsa, padding
|
| 10 |
+
from cryptography.hazmat.primitives import hashes, serialization
|
| 11 |
+
|
| 12 |
+
# تنظیمات
|
| 13 |
+
CERT_WIDTH, CERT_HEIGHT = 900, 650
|
| 14 |
+
MARGIN = 30
|
| 15 |
+
BACKGROUND_COLOR = (255, 255, 250)
|
| 16 |
+
TITLE_COLOR = (20, 20, 20)
|
| 17 |
+
TEXT_COLOR = (40, 40, 40)
|
| 18 |
+
WATERMARK_COLOR = (60, 60, 60, 25)
|
| 19 |
+
NOISE_INTENSITY = 10000
|
| 20 |
+
|
| 21 |
+
# اطلاعات گواهی
|
| 22 |
+
cert_info = {
|
| 23 |
+
"Name": "Yasin",
|
| 24 |
+
"Last Name": "Aryanfard",
|
| 25 |
+
"User ID": "YSNRFD",
|
| 26 |
+
"Membership Date": "April 1, 2023",
|
| 27 |
+
"Issued Date": "June 28, 2025",
|
| 28 |
+
"Certificate ID": "OPENAI-YSN-APR2023-CERT1001",
|
| 29 |
+
"Signed By": "ChatGPT-4o",
|
| 30 |
+
"Model ID": "GPT4O-REP-TRUST-2025",
|
| 31 |
+
"Issuer": "OpenAI, Inc."
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
# ساخت کلیدهای RSA
|
| 35 |
+
def generate_rsa_keys():
|
| 36 |
+
private_key = rsa.generate_private_key(public_exponent=65537, key_size=2048)
|
| 37 |
+
public_key = private_key.public_key()
|
| 38 |
+
return private_key, public_key
|
| 39 |
+
|
| 40 |
+
# ذخیره کلیدها
|
| 41 |
+
def save_rsa_keys(private_key, public_key):
|
| 42 |
+
with open("private_key.pem", "wb") as f:
|
| 43 |
+
f.write(private_key.private_bytes(
|
| 44 |
+
encoding=serialization.Encoding.PEM,
|
| 45 |
+
format=serialization.PrivateFormat.TraditionalOpenSSL,
|
| 46 |
+
encryption_algorithm=serialization.NoEncryption()
|
| 47 |
+
))
|
| 48 |
+
with open("public_key.pem", "wb") as f:
|
| 49 |
+
f.write(public_key.public_bytes(
|
| 50 |
+
encoding=serialization.Encoding.PEM,
|
| 51 |
+
format=serialization.PublicFormat.SubjectPublicKeyInfo
|
| 52 |
+
))
|
| 53 |
+
|
| 54 |
+
# بارگذاری فونت ساده (میتوان پیشرفتهتر کرد)
|
| 55 |
+
def load_font(name, size):
|
| 56 |
+
paths = [
|
| 57 |
+
name,
|
| 58 |
+
os.path.join("/usr/share/fonts/truetype/dejavu/", name),
|
| 59 |
+
os.path.join("/Library/Fonts/", name),
|
| 60 |
+
os.path.join("C:/Windows/Fonts/", name)
|
| 61 |
+
]
|
| 62 |
+
for path in paths:
|
| 63 |
+
try:
|
| 64 |
+
return ImageFont.truetype(path, size)
|
| 65 |
+
except:
|
| 66 |
+
continue
|
| 67 |
+
return ImageFont.load_default()
|
| 68 |
+
|
| 69 |
+
font_title = load_font("timesbd.ttf", 36)
|
| 70 |
+
font_text = load_font("times.ttf", 18)
|
| 71 |
+
font_small = load_font("times.ttf", 14)
|
| 72 |
+
|
| 73 |
+
# ساخت گرادیانت پسزمینه
|
| 74 |
+
def draw_gradient(draw, width, height, start_color, end_color):
|
| 75 |
+
for i in range(height):
|
| 76 |
+
r = int(start_color[0] + (float(i) / height) * (end_color[0] - start_color[0]))
|
| 77 |
+
g = int(start_color[1] + (float(i) / height) * (end_color[1] - start_color[1]))
|
| 78 |
+
b = int(start_color[2] + (float(i) / height) * (end_color[2] - start_color[2]))
|
| 79 |
+
draw.line([(0, i), (width, i)], fill=(r, g, b))
|
| 80 |
+
|
| 81 |
+
# ساخت QR code
|
| 82 |
+
def create_qr_code(data, size=180):
|
| 83 |
+
qr = qrcode.QRCode(box_size=8, border=3)
|
| 84 |
+
qr.add_data(data)
|
| 85 |
+
qr.make(fit=True)
|
| 86 |
+
qr_img = qr.make_image(fill_color="#003366", back_color="white").convert("RGBA")
|
| 87 |
+
qr_img = qr_img.resize((size, size), Image.Resampling.LANCZOS)
|
| 88 |
+
return qr_img
|
| 89 |
+
|
| 90 |
+
def encode_message_in_pixels(img, message):
|
| 91 |
+
binary_message = ''.join(format(ord(i), '08b') for i in message)
|
| 92 |
+
pixels = img.load()
|
| 93 |
+
width, height = img.size
|
| 94 |
+
idx = 0
|
| 95 |
+
for y in range(height):
|
| 96 |
+
for x in range(width):
|
| 97 |
+
if idx >= len(binary_message):
|
| 98 |
+
return
|
| 99 |
+
r, g, b, a = pixels[x, y]
|
| 100 |
+
r = (r & ~1) | int(binary_message[idx])
|
| 101 |
+
pixels[x, y] = (r, g, b, a)
|
| 102 |
+
idx += 1
|
| 103 |
+
|
| 104 |
+
def main():
|
| 105 |
+
private_key, public_key = generate_rsa_keys()
|
| 106 |
+
save_rsa_keys(private_key, public_key)
|
| 107 |
+
|
| 108 |
+
# دادههای برای امضا
|
| 109 |
+
data_string = "\n".join(f"{k}: {v}" for k, v in cert_info.items()).encode('utf-8')
|
| 110 |
+
|
| 111 |
+
digital_signature_bytes = private_key.sign(
|
| 112 |
+
data_string,
|
| 113 |
+
padding.PSS(
|
| 114 |
+
mgf=padding.MGF1(hashes.SHA256()),
|
| 115 |
+
salt_length=padding.PSS.MAX_LENGTH
|
| 116 |
+
),
|
| 117 |
+
hashes.SHA256()
|
| 118 |
+
)
|
| 119 |
+
digital_signature = base64.b64encode(digital_signature_bytes).decode('utf-8')
|
| 120 |
+
verification_code = f"VER-{hashlib.sha256(data_string).hexdigest()[:8].upper()}-{cert_info['Certificate ID'][-4:]}"
|
| 121 |
+
|
| 122 |
+
qr_img = create_qr_code(digital_signature, size=180)
|
| 123 |
+
|
| 124 |
+
certificate = Image.new("RGBA", (CERT_WIDTH, CERT_HEIGHT), BACKGROUND_COLOR)
|
| 125 |
+
draw = ImageDraw.Draw(certificate)
|
| 126 |
+
draw_gradient(draw, CERT_WIDTH, CERT_HEIGHT, (255, 255, 250), (220, 230, 255))
|
| 127 |
+
|
| 128 |
+
title_text = "OpenAI – Certificate of Membership"
|
| 129 |
+
w, h = draw.textsize(title_text, font=font_title)
|
| 130 |
+
draw.text(((CERT_WIDTH - w) / 2, MARGIN + 10), title_text, fill=TITLE_COLOR, font=font_title)
|
| 131 |
+
|
| 132 |
+
info_x, info_y = MARGIN + 30, MARGIN + 70
|
| 133 |
+
line_spacing = 36
|
| 134 |
+
for key, val in cert_info.items():
|
| 135 |
+
text_line = f"{key}: {val}"
|
| 136 |
+
draw.text((info_x, info_y), text_line, font=font_text, fill=TEXT_COLOR)
|
| 137 |
+
info_y += line_spacing
|
| 138 |
+
|
| 139 |
+
verification_label = "Verification Code:"
|
| 140 |
+
draw.text((info_x, info_y + 20), verification_label, font=font_text, fill=TEXT_COLOR)
|
| 141 |
+
draw.text((info_x + 190, info_y + 20), verification_code, font=font_text, fill=(0, 70, 120))
|
| 142 |
+
|
| 143 |
+
sig_lines = [digital_signature[i:i+60] for i in range(0, len(digital_signature), 60)]
|
| 144 |
+
sig_y = info_y + 60
|
| 145 |
+
for line in sig_lines:
|
| 146 |
+
draw.text((info_x, sig_y), line, font=font_small, fill=(100, 100, 120))
|
| 147 |
+
sig_y += 20
|
| 148 |
+
|
| 149 |
+
qr_pos = (CERT_WIDTH - qr_img.width - MARGIN - 20, CERT_HEIGHT - qr_img.height - MARGIN - 20)
|
| 150 |
+
certificate.paste(qr_img, qr_pos, qr_img)
|
| 151 |
+
|
| 152 |
+
# درج پیام مخفی استگانوگرافی (CertificateID و VerificationCode)
|
| 153 |
+
hidden_message = f"CertificateID:{cert_info['Certificate ID']};VerificationCode:{verification_code}"
|
| 154 |
+
encode_message_in_pixels(certificate, hidden_message)
|
| 155 |
+
|
| 156 |
+
output_file = "openai_certificate_yasin_realistic2.png"
|
| 157 |
+
certificate.convert("RGB").save(output_file, quality=95)
|
| 158 |
+
print(f"✅ Certificate created and saved as: {output_file}")
|
| 159 |
+
|
| 160 |
+
if __name__ == "__main__":
|
| 161 |
+
main()
|
cert/cert2.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import qrcode
|
| 2 |
+
from PIL import Image, ImageDraw, ImageFont
|
| 3 |
+
import hashlib
|
| 4 |
+
|
| 5 |
+
# ===== Certificate Info =====
|
| 6 |
+
name = "Yasin"
|
| 7 |
+
user_id = "YSNRFD"
|
| 8 |
+
membership_date = "April 1, 2023"
|
| 9 |
+
issued_date = "June 28, 2025"
|
| 10 |
+
certificate_id = "OPENAI-YSN-APR2023-CERT1001"
|
| 11 |
+
signed_by = "ChatGPT-4o"
|
| 12 |
+
model_id = "GPT4O-REP-TRUST-2025"
|
| 13 |
+
issuer = "OpenAI, Inc."
|
| 14 |
+
|
| 15 |
+
# Prepare data string for digital signature
|
| 16 |
+
data_string = f"""
|
| 17 |
+
Name: {name}
|
| 18 |
+
User ID: {user_id}
|
| 19 |
+
Membership Date: {membership_date}
|
| 20 |
+
Issued Date: {issued_date}
|
| 21 |
+
Certificate ID: {certificate_id}
|
| 22 |
+
Signed By: {signed_by}
|
| 23 |
+
Model ID: {model_id}
|
| 24 |
+
Issuer: {issuer}
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
# Generate SHA-256 digital signature
|
| 28 |
+
digital_signature = hashlib.sha256(data_string.encode('utf-8')).hexdigest()
|
| 29 |
+
verification_code = f"VER-{digital_signature[:8].upper()}-{certificate_id[-4:]}"
|
| 30 |
+
|
| 31 |
+
# Construct verification URL
|
| 32 |
+
verification_url = f"https://openai.com/verify?code={verification_code}"
|
| 33 |
+
|
| 34 |
+
# Create QR code from digital signature (or میتوانید از verification_url استفاده کنید)
|
| 35 |
+
qr = qrcode.QRCode(box_size=7, border=3)
|
| 36 |
+
qr.add_data(verification_url) # بهتر است QR کد لینک اعتبارسنجی باشد
|
| 37 |
+
qr.make(fit=True)
|
| 38 |
+
qr_img = qr.make_image(fill_color="black", back_color="white").convert("RGBA")
|
| 39 |
+
|
| 40 |
+
# Load fonts with fallback
|
| 41 |
+
try:
|
| 42 |
+
font_title = ImageFont.truetype("arialbd.ttf", 30)
|
| 43 |
+
font_header = ImageFont.truetype("arialbd.ttf", 18)
|
| 44 |
+
font_text = ImageFont.truetype("arial.ttf", 16)
|
| 45 |
+
font_small = ImageFont.truetype("arial.ttf", 14)
|
| 46 |
+
except:
|
| 47 |
+
font_title = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 30)
|
| 48 |
+
font_header = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 18)
|
| 49 |
+
font_text = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 16)
|
| 50 |
+
font_small = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 14)
|
| 51 |
+
|
| 52 |
+
# Create certificate canvas
|
| 53 |
+
width, height = 850, 580 # ارتفاع کمی بیشتر برای جای لینک
|
| 54 |
+
certificate = Image.new("RGB", (width, height), "#fffefa")
|
| 55 |
+
draw = ImageDraw.Draw(certificate)
|
| 56 |
+
|
| 57 |
+
# Background rectangle and divider line
|
| 58 |
+
draw.rectangle([(15, 15), (width-15, height-15)], outline="#555555", width=3)
|
| 59 |
+
draw.line([(20, 80), (width-20, 80)], fill="#999999", width=2)
|
| 60 |
+
|
| 61 |
+
# Title text
|
| 62 |
+
draw.text((40, 30), "OpenAI – Certificate of Membership", font=font_title, fill="#222222")
|
| 63 |
+
|
| 64 |
+
# Certificate info lines
|
| 65 |
+
info_lines = [
|
| 66 |
+
f"Name: {name}",
|
| 67 |
+
f"User ID: {user_id}",
|
| 68 |
+
f"Membership Date: {membership_date}",
|
| 69 |
+
f"Issued Date: {issued_date}",
|
| 70 |
+
f"Certificate ID: {certificate_id}",
|
| 71 |
+
f"Signed By: {signed_by}",
|
| 72 |
+
f"Model ID: {model_id}",
|
| 73 |
+
f"Issuer: {issuer}",
|
| 74 |
+
]
|
| 75 |
+
|
| 76 |
+
y_text = 100
|
| 77 |
+
for line in info_lines:
|
| 78 |
+
draw.text((40, y_text), line, font=font_text, fill="#333333")
|
| 79 |
+
y_text += 30
|
| 80 |
+
|
| 81 |
+
# Verification code
|
| 82 |
+
draw.text((40, y_text + 10), f"Verification Code: {verification_code}", font=font_header, fill="#444444")
|
| 83 |
+
|
| 84 |
+
# Digital signature label and text
|
| 85 |
+
draw.text((40, y_text + 50), "SHA-256 Digital Signature:", font=font_header, fill="#222222")
|
| 86 |
+
|
| 87 |
+
sig_1 = digital_signature[:len(digital_signature)//2]
|
| 88 |
+
sig_2 = digital_signature[len(digital_signature)//2:]
|
| 89 |
+
draw.text((40, y_text + 80), sig_1, font=font_small, fill="#555555")
|
| 90 |
+
draw.text((40, y_text + 100), sig_2, font=font_small, fill="#555555")
|
| 91 |
+
|
| 92 |
+
# Draw verification URL below signature
|
| 93 |
+
draw.text((40, y_text + 140), "Verify this certificate online at:", font=font_header, fill="#222222")
|
| 94 |
+
draw.text((40, y_text + 170), verification_url, font=font_small, fill="blue")
|
| 95 |
+
|
| 96 |
+
# Paste QR code on bottom right
|
| 97 |
+
qr_size = 150
|
| 98 |
+
qr_position = (width - qr_size - 40, height - qr_size - 40)
|
| 99 |
+
qr_img = qr_img.resize((qr_size, qr_size), Image.Resampling.LANCZOS)
|
| 100 |
+
certificate.paste(qr_img, qr_position, qr_img)
|
| 101 |
+
|
| 102 |
+
# Draw a professional OpenAI seal
|
| 103 |
+
seal_diameter = 140
|
| 104 |
+
seal = Image.new("RGBA", (seal_diameter, seal_diameter), (255, 255, 255, 0))
|
| 105 |
+
seal_draw = ImageDraw.Draw(seal)
|
| 106 |
+
|
| 107 |
+
for i in range(seal_diameter//2, 0, -1):
|
| 108 |
+
color_val = 40 + int((seal_diameter//2 - i) * 1.5)
|
| 109 |
+
color = (color_val, color_val, color_val, 255)
|
| 110 |
+
seal_draw.ellipse(
|
| 111 |
+
[seal_diameter//2 - i, seal_diameter//2 - i, seal_diameter//2 + i, seal_diameter//2 + i],
|
| 112 |
+
fill=color
|
| 113 |
+
)
|
| 114 |
+
|
| 115 |
+
text = "OpenAI"
|
| 116 |
+
bbox = seal_draw.textbbox((0, 0), text, font=font_header)
|
| 117 |
+
w = bbox[2] - bbox[0]
|
| 118 |
+
h = bbox[3] - bbox[1]
|
| 119 |
+
text_pos = ((seal_diameter - w)//2, (seal_diameter - h)//2)
|
| 120 |
+
|
| 121 |
+
seal_draw.text((text_pos[0]+2, text_pos[1]+2), text, font=font_header, fill=(20, 20, 20, 255))
|
| 122 |
+
seal_draw.text(text_pos, text, font=font_header, fill=(240, 240, 240, 255))
|
| 123 |
+
|
| 124 |
+
certificate.paste(seal, (width - seal_diameter - 40, 40), seal)
|
| 125 |
+
|
| 126 |
+
# Save certificate image
|
| 127 |
+
certificate.save("openai_certificate_yasin_en_with_verification_link.png")
|
| 128 |
+
print("✅ Certificate image created: openai_certificate_yasin_en_with_verification_link.png")
|
cert/cert3.py
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from PIL import Image, ImageDraw, ImageFont
|
| 2 |
+
import math
|
| 3 |
+
import qrcode
|
| 4 |
+
from PIL import Image, ImageDraw, ImageFont
|
| 5 |
+
import hashlib
|
| 6 |
+
|
| 7 |
+
# ===== Certificate Info =====
|
| 8 |
+
name = "Yasin"
|
| 9 |
+
user_id = "YSNRFD"
|
| 10 |
+
membership_date = "April 1, 2023"
|
| 11 |
+
issued_date = "June 28, 2025"
|
| 12 |
+
certificate_id = "OPENAI-YSN-APR2023-CERT1001"
|
| 13 |
+
signed_by = "ChatGPT-4o"
|
| 14 |
+
model_id = "GPT4O-REP-TRUST-2025"
|
| 15 |
+
issuer = "OpenAI, Inc."
|
| 16 |
+
|
| 17 |
+
# Prepare data string for digital signature
|
| 18 |
+
data_string = f"""
|
| 19 |
+
Name: {name}
|
| 20 |
+
User ID: {user_id}
|
| 21 |
+
Membership Date: {membership_date}
|
| 22 |
+
Issued Date: {issued_date}
|
| 23 |
+
Certificate ID: {certificate_id}
|
| 24 |
+
Signed By: {signed_by}
|
| 25 |
+
Model ID: {model_id}
|
| 26 |
+
Issuer: {issuer}
|
| 27 |
+
"""
|
| 28 |
+
|
| 29 |
+
# Generate SHA-256 digital signature
|
| 30 |
+
digital_signature = hashlib.sha256(data_string.encode('utf-8')).hexdigest()
|
| 31 |
+
verification_code = f"VER-{digital_signature[:8].upper()}-{certificate_id[-4:]}"
|
| 32 |
+
|
| 33 |
+
# Create QR code from digital signature
|
| 34 |
+
qr = qrcode.QRCode(box_size=7, border=3)
|
| 35 |
+
qr.add_data(digital_signature)
|
| 36 |
+
qr.make(fit=True)
|
| 37 |
+
qr_img = qr.make_image(fill_color="black", back_color="white").convert("RGBA")
|
| 38 |
+
|
| 39 |
+
# Load fonts with fallback
|
| 40 |
+
try:
|
| 41 |
+
font_title = ImageFont.truetype("arialbd.ttf", 30)
|
| 42 |
+
font_header = ImageFont.truetype("arialbd.ttf", 18)
|
| 43 |
+
font_text = ImageFont.truetype("arial.ttf", 16)
|
| 44 |
+
font_small = ImageFont.truetype("arial.ttf", 14)
|
| 45 |
+
except:
|
| 46 |
+
font_title = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 30)
|
| 47 |
+
font_header = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 18)
|
| 48 |
+
font_text = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 16)
|
| 49 |
+
font_small = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 14)
|
| 50 |
+
|
| 51 |
+
# Create certificate canvas
|
| 52 |
+
width, height = 850, 520
|
| 53 |
+
certificate = Image.new("RGB", (width, height), "#fffefa")
|
| 54 |
+
draw = ImageDraw.Draw(certificate)
|
| 55 |
+
|
| 56 |
+
# Background rectangle and divider line
|
| 57 |
+
draw.rectangle([(15, 15), (width-15, height-15)], outline="#555555", width=3)
|
| 58 |
+
draw.line([(20, 80), (width-20, 80)], fill="#999999", width=2)
|
| 59 |
+
|
| 60 |
+
# Title text
|
| 61 |
+
draw.text((40, 30), "OpenAI – Certificate of Membership", font=font_title, fill="#222222")
|
| 62 |
+
|
| 63 |
+
# Certificate info lines
|
| 64 |
+
info_lines = [
|
| 65 |
+
f"Name: {name}",
|
| 66 |
+
f"User ID: {user_id}",
|
| 67 |
+
f"Membership Date: {membership_date}",
|
| 68 |
+
f"Issued Date: {issued_date}",
|
| 69 |
+
f"Certificate ID: {certificate_id}",
|
| 70 |
+
f"Signed By: {signed_by}",
|
| 71 |
+
f"Model ID: {model_id}",
|
| 72 |
+
f"Issuer: {issuer}",
|
| 73 |
+
]
|
| 74 |
+
|
| 75 |
+
y_text = 100
|
| 76 |
+
for line in info_lines:
|
| 77 |
+
draw.text((40, y_text), line, font=font_text, fill="#333333")
|
| 78 |
+
y_text += 30
|
| 79 |
+
|
| 80 |
+
# Verification code
|
| 81 |
+
draw.text((40, y_text + 10), f"Verification Code: {verification_code}", font=font_header, fill="#444444")
|
| 82 |
+
|
| 83 |
+
# Digital signature label and text
|
| 84 |
+
draw.text((40, y_text + 50), "SHA-256 Digital Signature:", font=font_header, fill="#222222")
|
| 85 |
+
|
| 86 |
+
sig_1 = digital_signature[:len(digital_signature)//2]
|
| 87 |
+
sig_2 = digital_signature[len(digital_signature)//2:]
|
| 88 |
+
draw.text((40, y_text + 80), sig_1, font=font_small, fill="#555555")
|
| 89 |
+
draw.text((40, y_text + 100), sig_2, font=font_small, fill="#555555")
|
| 90 |
+
|
| 91 |
+
# Paste QR code on bottom right
|
| 92 |
+
qr_size = 150
|
| 93 |
+
qr_position = (width - qr_size - 40, height - qr_size - 40)
|
| 94 |
+
qr_img = qr_img.resize((qr_size, qr_size), Image.Resampling.LANCZOS)
|
| 95 |
+
certificate.paste(qr_img, qr_position, qr_img)
|
| 96 |
+
|
| 97 |
+
# Draw a professional OpenAI seal
|
| 98 |
+
seal_diameter = 140
|
| 99 |
+
seal = Image.new("RGBA", (seal_diameter, seal_diameter), (255, 255, 255, 0))
|
| 100 |
+
seal_draw = ImageDraw.Draw(seal)
|
| 101 |
+
|
| 102 |
+
# Simple radial gradient circle for seal
|
| 103 |
+
for i in range(seal_diameter//2, 0, -1):
|
| 104 |
+
color_val = 40 + int((seal_diameter//2 - i) * 1.5)
|
| 105 |
+
color = (color_val, color_val, color_val, 255)
|
| 106 |
+
seal_draw.ellipse(
|
| 107 |
+
[seal_diameter//2 - i, seal_diameter//2 - i, seal_diameter//2 + i, seal_diameter//2 + i],
|
| 108 |
+
fill=color
|
| 109 |
+
)
|
| 110 |
+
|
| 111 |
+
# Seal text with shadow
|
| 112 |
+
# Seal text with shadow
|
| 113 |
+
text = "OpenAI"
|
| 114 |
+
bbox = seal_draw.textbbox((0, 0), text, font=font_header)
|
| 115 |
+
w = bbox[2] - bbox[0]
|
| 116 |
+
h = bbox[3] - bbox[1]
|
| 117 |
+
text_pos = ((seal_diameter - w)//2, (seal_diameter - h)//2)
|
| 118 |
+
|
| 119 |
+
# سایه
|
| 120 |
+
seal_draw.text((text_pos[0]+2, text_pos[1]+2), text, font=font_header, fill=(20, 20, 20, 255))
|
| 121 |
+
# متن اصلی
|
| 122 |
+
seal_draw.text(text_pos, text, font=font_header, fill=(240, 240, 240, 255))
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
# Paste seal on top right
|
| 126 |
+
certificate.paste(seal, (width - seal_diameter - 40, 40), seal)
|
| 127 |
+
|
| 128 |
+
# Save certificate image
|
| 129 |
+
certificate.save("openai_certificate_yasin_en.png")
|
| 130 |
+
print("✅ Certificate image created: openai_certificate_yasin_en.png")
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
# Draw a professional OpenAI seal (more realistic)
|
| 134 |
+
seal_diameter = 160
|
| 135 |
+
seal = Image.new("RGBA", (seal_diameter, seal_diameter), (255, 255, 255, 0))
|
| 136 |
+
seal_draw = ImageDraw.Draw(seal)
|
| 137 |
+
|
| 138 |
+
center = seal_diameter // 2
|
| 139 |
+
|
| 140 |
+
# Outer ring (thick)
|
| 141 |
+
seal_draw.ellipse(
|
| 142 |
+
[(5, 5), (seal_diameter - 5, seal_diameter - 5)],
|
| 143 |
+
outline=(0, 51, 102, 255), width=8
|
| 144 |
+
)
|
| 145 |
+
|
| 146 |
+
# Inner ring (thin)
|
| 147 |
+
seal_draw.ellipse(
|
| 148 |
+
[(20, 20), (seal_diameter - 20, seal_diameter - 20)],
|
| 149 |
+
outline=(0, 102, 204, 255), width=3
|
| 150 |
+
)
|
| 151 |
+
|
| 152 |
+
# Radial lines (like sun rays)
|
| 153 |
+
num_rays = 24
|
| 154 |
+
for i in range(num_rays):
|
| 155 |
+
angle = (360 / num_rays) * i
|
| 156 |
+
# Calculate start and end points of each ray
|
| 157 |
+
start_x = center + int( (seal_diameter//2 - 20) * math.cos(math.radians(angle)) )
|
| 158 |
+
start_y = center + int( (seal_diameter//2 - 20) * math.sin(math.radians(angle)) )
|
| 159 |
+
end_x = center + int( (seal_diameter//2 - 5) * math.cos(math.radians(angle)) )
|
| 160 |
+
end_y = center + int( (seal_diameter//2 - 5) * math.sin(math.radians(angle)) )
|
| 161 |
+
seal_draw.line([(start_x, start_y), (end_x, end_y)], fill=(0, 51, 102, 180), width=2)
|
| 162 |
+
|
| 163 |
+
# Text around the circle
|
| 164 |
+
import math
|
| 165 |
+
|
| 166 |
+
seal_text = "OFFICIAL SEAL OF OPENAI"
|
| 167 |
+
font_seal = font_header # از فونت اصلی استفاده کن یا فونت مناسب دیگه
|
| 168 |
+
radius_text = seal_diameter // 2 - 30
|
| 169 |
+
|
| 170 |
+
for i, char in enumerate(seal_text):
|
| 171 |
+
angle = 180 + (i * (360 / len(seal_text))) # چرخش متن دور دایره
|
| 172 |
+
x = center + int(radius_text * math.cos(math.radians(angle)))
|
| 173 |
+
y = center + int(radius_text * math.sin(math.radians(angle)))
|
| 174 |
+
seal_draw.text((x-7, y-7), char, font=font_seal, fill=(0, 51, 102, 255))
|
| 175 |
+
|
| 176 |
+
# Center text (Organization Name)
|
| 177 |
+
center_text = "OpenAI"
|
| 178 |
+
bbox = seal_draw.textbbox((0, 0), center_text, font=font_title)
|
| 179 |
+
w = bbox[2] - bbox[0]
|
| 180 |
+
h = bbox[3] - bbox[1]
|
| 181 |
+
seal_draw.text(((seal_diameter - w)//2, (seal_diameter - h)//2), center_text, font=font_title, fill=(0, 51, 102, 255))
|
| 182 |
+
|
| 183 |
+
# Simulated signature below center text
|
| 184 |
+
signature_text = "Digitally Signed"
|
| 185 |
+
sig_font = font_small
|
| 186 |
+
sig_bbox = seal_draw.textbbox((0,0), signature_text, font=sig_font)
|
| 187 |
+
sw = sig_bbox[2] - sig_bbox[0]
|
| 188 |
+
sh = sig_bbox[3] - sig_bbox[1]
|
| 189 |
+
seal_draw.text(((seal_diameter - sw)//2, (seal_diameter + h)//2 + 5), signature_text, font=sig_font, fill=(0, 51, 102, 180))
|
| 190 |
+
|
| 191 |
+
# Paste seal on top right
|
| 192 |
+
certificate.paste(seal, (width - seal_diameter - 40, 40), seal)
|
cert/cert4.py
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from PIL import Image, ImageDraw, ImageFont
|
| 2 |
+
import math
|
| 3 |
+
|
| 4 |
+
from PIL import Image, ImageDraw, ImageFont
|
| 5 |
+
import math
|
| 6 |
+
import qrcode
|
| 7 |
+
from PIL import Image, ImageDraw, ImageFont
|
| 8 |
+
import hashlib
|
| 9 |
+
|
| 10 |
+
# ===== Certificate Info =====
|
| 11 |
+
name = "Yasin"
|
| 12 |
+
user_id = "YSNRFD"
|
| 13 |
+
membership_date = "April 1, 2023"
|
| 14 |
+
issued_date = "June 28, 2025"
|
| 15 |
+
certificate_id = "OPENAI-YSN-APR2023-CERT1001"
|
| 16 |
+
signed_by = "ChatGPT-4o"
|
| 17 |
+
model_id = "GPT4O-REP-TRUST-2025"
|
| 18 |
+
issuer = "OpenAI, Inc."
|
| 19 |
+
|
| 20 |
+
# Prepare data string for digital signature
|
| 21 |
+
data_string = f"""
|
| 22 |
+
Name: {name}
|
| 23 |
+
User ID: {user_id}
|
| 24 |
+
Membership Date: {membership_date}
|
| 25 |
+
Issued Date: {issued_date}
|
| 26 |
+
Certificate ID: {certificate_id}
|
| 27 |
+
Signed By: {signed_by}
|
| 28 |
+
Model ID: {model_id}
|
| 29 |
+
Issuer: {issuer}
|
| 30 |
+
"""
|
| 31 |
+
|
| 32 |
+
# Generate SHA-256 digital signature
|
| 33 |
+
digital_signature = hashlib.sha256(data_string.encode('utf-8')).hexdigest()
|
| 34 |
+
verification_code = f"VER-{digital_signature[:8].upper()}-{certificate_id[-4:]}"
|
| 35 |
+
|
| 36 |
+
# Create QR code from digital signature
|
| 37 |
+
qr = qrcode.QRCode(box_size=7, border=3)
|
| 38 |
+
qr.add_data(digital_signature)
|
| 39 |
+
qr.make(fit=True)
|
| 40 |
+
qr_img = qr.make_image(fill_color="black", back_color="white").convert("RGBA")
|
| 41 |
+
|
| 42 |
+
# Load fonts with fallback
|
| 43 |
+
try:
|
| 44 |
+
font_title = ImageFont.truetype("arialbd.ttf", 30)
|
| 45 |
+
font_header = ImageFont.truetype("arialbd.ttf", 18)
|
| 46 |
+
font_text = ImageFont.truetype("arial.ttf", 16)
|
| 47 |
+
font_small = ImageFont.truetype("arial.ttf", 14)
|
| 48 |
+
except:
|
| 49 |
+
font_title = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 30)
|
| 50 |
+
font_header = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 18)
|
| 51 |
+
font_text = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 16)
|
| 52 |
+
font_small = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 14)
|
| 53 |
+
|
| 54 |
+
# Create certificate canvas
|
| 55 |
+
width, height = 850, 520
|
| 56 |
+
certificate = Image.new("RGB", (width, height), "#fffefa")
|
| 57 |
+
draw = ImageDraw.Draw(certificate)
|
| 58 |
+
|
| 59 |
+
# Background rectangle and divider line
|
| 60 |
+
draw.rectangle([(15, 15), (width-15, height-15)], outline="#555555", width=3)
|
| 61 |
+
draw.line([(20, 80), (width-20, 80)], fill="#999999", width=2)
|
| 62 |
+
|
| 63 |
+
# Title text
|
| 64 |
+
draw.text((40, 30), "OpenAI – Certificate of Membership", font=font_title, fill="#222222")
|
| 65 |
+
|
| 66 |
+
# Certificate info lines
|
| 67 |
+
info_lines = [
|
| 68 |
+
f"Name: {name}",
|
| 69 |
+
f"User ID: {user_id}",
|
| 70 |
+
f"Membership Date: {membership_date}",
|
| 71 |
+
f"Issued Date: {issued_date}",
|
| 72 |
+
f"Certificate ID: {certificate_id}",
|
| 73 |
+
f"Signed By: {signed_by}",
|
| 74 |
+
f"Model ID: {model_id}",
|
| 75 |
+
f"Issuer: {issuer}",
|
| 76 |
+
]
|
| 77 |
+
|
| 78 |
+
y_text = 100
|
| 79 |
+
for line in info_lines:
|
| 80 |
+
draw.text((40, y_text), line, font=font_text, fill="#333333")
|
| 81 |
+
y_text += 30
|
| 82 |
+
|
| 83 |
+
# Verification code
|
| 84 |
+
draw.text((40, y_text + 10), f"Verification Code: {verification_code}", font=font_header, fill="#444444")
|
| 85 |
+
|
| 86 |
+
# Digital signature label and text
|
| 87 |
+
draw.text((40, y_text + 50), "SHA-256 Digital Signature:", font=font_header, fill="#222222")
|
| 88 |
+
|
| 89 |
+
sig_1 = digital_signature[:len(digital_signature)//2]
|
| 90 |
+
sig_2 = digital_signature[len(digital_signature)//2:]
|
| 91 |
+
draw.text((40, y_text + 80), sig_1, font=font_small, fill="#555555")
|
| 92 |
+
draw.text((40, y_text + 100), sig_2, font=font_small, fill="#555555")
|
| 93 |
+
|
| 94 |
+
# Paste QR code on bottom right
|
| 95 |
+
qr_size = 150
|
| 96 |
+
qr_position = (width - qr_size - 40, height - qr_size - 40)
|
| 97 |
+
qr_img = qr_img.resize((qr_size, qr_size), Image.Resampling.LANCZOS)
|
| 98 |
+
certificate.paste(qr_img, qr_position, qr_img)
|
| 99 |
+
|
| 100 |
+
# Draw a professional OpenAI seal
|
| 101 |
+
seal_diameter = 140
|
| 102 |
+
seal = Image.new("RGBA", (seal_diameter, seal_diameter), (255, 255, 255, 0))
|
| 103 |
+
seal_draw = ImageDraw.Draw(seal)
|
| 104 |
+
|
| 105 |
+
# Simple radial gradient circle for seal
|
| 106 |
+
for i in range(seal_diameter//2, 0, -1):
|
| 107 |
+
color_val = 40 + int((seal_diameter//2 - i) * 1.5)
|
| 108 |
+
color = (color_val, color_val, color_val, 255)
|
| 109 |
+
seal_draw.ellipse(
|
| 110 |
+
[seal_diameter//2 - i, seal_diameter//2 - i, seal_diameter//2 + i, seal_diameter//2 + i],
|
| 111 |
+
fill=color
|
| 112 |
+
)
|
| 113 |
+
|
| 114 |
+
# Seal text with shadow
|
| 115 |
+
# Seal text with shadow
|
| 116 |
+
text = "OpenAI"
|
| 117 |
+
bbox = seal_draw.textbbox((0, 0), text, font=font_header)
|
| 118 |
+
w = bbox[2] - bbox[0]
|
| 119 |
+
h = bbox[3] - bbox[1]
|
| 120 |
+
text_pos = ((seal_diameter - w)//2, (seal_diameter - h)//2)
|
| 121 |
+
|
| 122 |
+
# سایه
|
| 123 |
+
seal_draw.text((text_pos[0]+2, text_pos[1]+2), text, font=font_header, fill=(20, 20, 20, 255))
|
| 124 |
+
# متن اصلی
|
| 125 |
+
seal_draw.text(text_pos, text, font=font_header, fill=(240, 240, 240, 255))
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
# Paste seal on top right
|
| 129 |
+
certificate.paste(seal, (width - seal_diameter - 40, 40), seal)
|
| 130 |
+
|
| 131 |
+
# Save certificate image
|
| 132 |
+
certificate.save("openai_certificate_yasin_en_2.png")
|
| 133 |
+
print("✅ Certificate image created: openai_certificate_yasin_en.png")
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
# Draw a professional OpenAI seal (more realistic)
|
| 137 |
+
seal_diameter = 160
|
| 138 |
+
seal = Image.new("RGBA", (seal_diameter, seal_diameter), (255, 255, 255, 0))
|
| 139 |
+
seal_draw = ImageDraw.Draw(seal)
|
| 140 |
+
|
| 141 |
+
center = seal_diameter // 2
|
| 142 |
+
|
| 143 |
+
# Outer ring (thick)
|
| 144 |
+
seal_draw.ellipse(
|
| 145 |
+
[(5, 5), (seal_diameter - 5, seal_diameter - 5)],
|
| 146 |
+
outline=(0, 51, 102, 255), width=8
|
| 147 |
+
)
|
| 148 |
+
|
| 149 |
+
# Inner ring (thin)
|
| 150 |
+
seal_draw.ellipse(
|
| 151 |
+
[(20, 20), (seal_diameter - 20, seal_diameter - 20)],
|
| 152 |
+
outline=(0, 102, 204, 255), width=3
|
| 153 |
+
)
|
| 154 |
+
|
| 155 |
+
# Radial lines (like sun rays)
|
| 156 |
+
num_rays = 24
|
| 157 |
+
for i in range(num_rays):
|
| 158 |
+
angle = (360 / num_rays) * i
|
| 159 |
+
# Calculate start and end points of each ray
|
| 160 |
+
start_x = center + int( (seal_diameter//2 - 20) * math.cos(math.radians(angle)) )
|
| 161 |
+
start_y = center + int( (seal_diameter//2 - 20) * math.sin(math.radians(angle)) )
|
| 162 |
+
end_x = center + int( (seal_diameter//2 - 5) * math.cos(math.radians(angle)) )
|
| 163 |
+
end_y = center + int( (seal_diameter//2 - 5) * math.sin(math.radians(angle)) )
|
| 164 |
+
seal_draw.line([(start_x, start_y), (end_x, end_y)], fill=(0, 51, 102, 180), width=2)
|
| 165 |
+
|
| 166 |
+
# Text around the circle
|
| 167 |
+
import math
|
| 168 |
+
|
| 169 |
+
seal_text = "OFFICIAL SEAL OF OPENAI"
|
| 170 |
+
font_seal = font_header # از فونت اصلی استفاده کن یا فونت مناسب دیگه
|
| 171 |
+
radius_text = seal_diameter // 2 - 30
|
| 172 |
+
|
| 173 |
+
for i, char in enumerate(seal_text):
|
| 174 |
+
angle = 180 + (i * (360 / len(seal_text))) # چرخش متن دور دایره
|
| 175 |
+
x = center + int(radius_text * math.cos(math.radians(angle)))
|
| 176 |
+
y = center + int(radius_text * math.sin(math.radians(angle)))
|
| 177 |
+
seal_draw.text((x-7, y-7), char, font=font_seal, fill=(0, 51, 102, 255))
|
| 178 |
+
|
| 179 |
+
# Center text (Organization Name)
|
| 180 |
+
center_text = "OpenAI"
|
| 181 |
+
bbox = seal_draw.textbbox((0, 0), center_text, font=font_title)
|
| 182 |
+
w = bbox[2] - bbox[0]
|
| 183 |
+
h = bbox[3] - bbox[1]
|
| 184 |
+
seal_draw.text(((seal_diameter - w)//2, (seal_diameter - h)//2), center_text, font=font_title, fill=(0, 51, 102, 255))
|
| 185 |
+
|
| 186 |
+
# Simulated signature below center text
|
| 187 |
+
signature_text = "Digitally Signed"
|
| 188 |
+
sig_font = font_small
|
| 189 |
+
sig_bbox = seal_draw.textbbox((0,0), signature_text, font=sig_font)
|
| 190 |
+
sw = sig_bbox[2] - sig_bbox[0]
|
| 191 |
+
sh = sig_bbox[3] - sig_bbox[1]
|
| 192 |
+
seal_draw.text(((seal_diameter - sw)//2, (seal_diameter + h)//2 + 5), signature_text, font=sig_font, fill=(0, 51, 102, 180))
|
| 193 |
+
|
| 194 |
+
# Paste seal on top right
|
| 195 |
+
certificate.paste(seal, (width - seal_diameter - 40, 40), seal)
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
# Load OpenAI logo (transparent PNG)
|
| 199 |
+
try:
|
| 200 |
+
logo = Image.open("openai_seal.png").convert("RGBA")
|
| 201 |
+
except FileNotFoundError:
|
| 202 |
+
print("⚠️ فایل لوگوی openai_logo.png پیدا نشد! لطفا لوگوی مناسب کنار اسکریپت قرار دهید.")
|
| 203 |
+
logo = None
|
| 204 |
+
|
| 205 |
+
# Draw a professional OpenAI seal with logo inside
|
| 206 |
+
seal_diameter = 160
|
| 207 |
+
seal = Image.new("RGBA", (seal_diameter, seal_diameter), (255, 255, 255, 0))
|
| 208 |
+
seal_draw = ImageDraw.Draw(seal)
|
| 209 |
+
|
| 210 |
+
center = seal_diameter // 2
|
| 211 |
+
|
| 212 |
+
# Outer thick ring
|
| 213 |
+
seal_draw.ellipse(
|
| 214 |
+
[(5, 5), (seal_diameter - 5, seal_diameter - 5)],
|
| 215 |
+
outline=(0, 51, 102, 255), width=8
|
| 216 |
+
)
|
| 217 |
+
|
| 218 |
+
# Inner thin ring
|
| 219 |
+
seal_draw.ellipse(
|
| 220 |
+
[(20, 20), (seal_diameter - 20, seal_diameter - 20)],
|
| 221 |
+
outline=(0, 102, 204, 255), width=3
|
| 222 |
+
)
|
| 223 |
+
|
| 224 |
+
# Add logo at center if loaded
|
| 225 |
+
if logo:
|
| 226 |
+
# Resize logo to fit inside inner circle
|
| 227 |
+
max_logo_size = seal_diameter - 60
|
| 228 |
+
logo = logo.resize((max_logo_size, max_logo_size), Image.Resampling.LANCZOS)
|
| 229 |
+
logo_pos = (center - max_logo_size // 2, center - max_logo_size // 2)
|
| 230 |
+
seal.paste(logo, logo_pos, logo) # Use logo as mask for transparency
|
| 231 |
+
|
| 232 |
+
# Optionally add text around seal (like قبلی) یا حذفش کن
|
| 233 |
+
|
| 234 |
+
# Paste seal on top right
|
| 235 |
+
certificate.paste(seal, (width - seal_diameter - 40, 40), seal)
|
cert/cert5.py
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from PIL import Image, ImageDraw, ImageFont
|
| 2 |
+
import math
|
| 3 |
+
import qrcode
|
| 4 |
+
import hashlib
|
| 5 |
+
|
| 6 |
+
# ===== Certificate Info =====
|
| 7 |
+
name = "Yasin"
|
| 8 |
+
user_id = "YSNRFD"
|
| 9 |
+
membership_date = "April 1, 2023"
|
| 10 |
+
issued_date = "June 28, 2025"
|
| 11 |
+
certificate_id = "OPENAI-YSN-APR2023-CERT1001"
|
| 12 |
+
signed_by = "ChatGPT-4o"
|
| 13 |
+
model_id = "GPT4O-REP-TRUST-2025"
|
| 14 |
+
issuer = "OpenAI, Inc."
|
| 15 |
+
|
| 16 |
+
# Prepare data string for digital signature
|
| 17 |
+
data_string = f"""
|
| 18 |
+
Name: {name}
|
| 19 |
+
User ID: {user_id}
|
| 20 |
+
Membership Date: {membership_date}
|
| 21 |
+
Issued Date: {issued_date}
|
| 22 |
+
Certificate ID: {certificate_id}
|
| 23 |
+
Signed By: {signed_by}
|
| 24 |
+
Model ID: {model_id}
|
| 25 |
+
Issuer: {issuer}
|
| 26 |
+
"""
|
| 27 |
+
|
| 28 |
+
# Generate SHA-256 digital signature
|
| 29 |
+
digital_signature = hashlib.sha256(data_string.encode('utf-8')).hexdigest()
|
| 30 |
+
verification_code = f"VER-{digital_signature[:8].upper()}-{certificate_id[-4:]}"
|
| 31 |
+
|
| 32 |
+
# Create QR code from digital signature
|
| 33 |
+
qr = qrcode.QRCode(box_size=7, border=3)
|
| 34 |
+
qr.add_data(digital_signature)
|
| 35 |
+
qr.make(fit=True)
|
| 36 |
+
qr_img = qr.make_image(fill_color="black", back_color="white").convert("RGBA")
|
| 37 |
+
|
| 38 |
+
# Load fonts with fallback
|
| 39 |
+
try:
|
| 40 |
+
font_title = ImageFont.truetype("arialbd.ttf", 30)
|
| 41 |
+
font_header = ImageFont.truetype("arialbd.ttf", 18)
|
| 42 |
+
font_text = ImageFont.truetype("arial.ttf", 16)
|
| 43 |
+
font_small = ImageFont.truetype("arial.ttf", 14)
|
| 44 |
+
except:
|
| 45 |
+
font_title = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 30)
|
| 46 |
+
font_header = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 18)
|
| 47 |
+
font_text = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 16)
|
| 48 |
+
font_small = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 14)
|
| 49 |
+
|
| 50 |
+
# Create certificate canvas
|
| 51 |
+
width, height = 850, 520
|
| 52 |
+
certificate = Image.new("RGB", (width, height), "#fffefa")
|
| 53 |
+
draw = ImageDraw.Draw(certificate)
|
| 54 |
+
|
| 55 |
+
# Background rectangle and divider line
|
| 56 |
+
draw.rectangle([(15, 15), (width-15, height-15)], outline="#555555", width=3)
|
| 57 |
+
draw.line([(20, 80), (width-20, 80)], fill="#999999", width=2)
|
| 58 |
+
|
| 59 |
+
# Title text
|
| 60 |
+
draw.text((40, 30), "OpenAI – Certificate of Membership", font=font_title, fill="#222222")
|
| 61 |
+
|
| 62 |
+
# Certificate info lines
|
| 63 |
+
info_lines = [
|
| 64 |
+
f"Name: {name}",
|
| 65 |
+
f"User ID: {user_id}",
|
| 66 |
+
f"Membership Date: {membership_date}",
|
| 67 |
+
f"Issued Date: {issued_date}",
|
| 68 |
+
f"Certificate ID: {certificate_id}",
|
| 69 |
+
f"Signed By: {signed_by}",
|
| 70 |
+
f"Model ID: {model_id}",
|
| 71 |
+
f"Issuer: {issuer}",
|
| 72 |
+
]
|
| 73 |
+
|
| 74 |
+
y_text = 100
|
| 75 |
+
for line in info_lines:
|
| 76 |
+
draw.text((40, y_text), line, font=font_text, fill="#333333")
|
| 77 |
+
y_text += 30
|
| 78 |
+
|
| 79 |
+
# Verification code
|
| 80 |
+
draw.text((40, y_text + 10), f"Verification Code: {verification_code}", font=font_header, fill="#444444")
|
| 81 |
+
|
| 82 |
+
# Digital signature label and text
|
| 83 |
+
draw.text((40, y_text + 50), "SHA-256 Digital Signature:", font=font_header, fill="#222222")
|
| 84 |
+
|
| 85 |
+
sig_1 = digital_signature[:len(digital_signature)//2]
|
| 86 |
+
sig_2 = digital_signature[len(digital_signature)//2:]
|
| 87 |
+
draw.text((40, y_text + 80), sig_1, font=font_small, fill="#555555")
|
| 88 |
+
draw.text((40, y_text + 100), sig_2, font=font_small, fill="#555555")
|
| 89 |
+
|
| 90 |
+
# Paste QR code on bottom right
|
| 91 |
+
qr_size = 150
|
| 92 |
+
qr_position = (width - qr_size - 40, height - qr_size - 40)
|
| 93 |
+
qr_img = qr_img.resize((qr_size, qr_size), Image.Resampling.LANCZOS)
|
| 94 |
+
certificate.paste(qr_img, qr_position, qr_img)
|
| 95 |
+
|
| 96 |
+
# ==== Draw a professional OpenAI seal with logo inside ====
|
| 97 |
+
|
| 98 |
+
# Load logo PNG (converted from your SVG to PNG, size approx 800x800)
|
| 99 |
+
try:
|
| 100 |
+
logo = Image.open("openai_seal.png").convert("RGBA")
|
| 101 |
+
except FileNotFoundError:
|
| 102 |
+
print("⚠️ فایل لوگوی my_logo.png پیدا نشد! لطفا لوگوی مناسب کنار اسکریپت قرار دهید.")
|
| 103 |
+
logo = None
|
| 104 |
+
|
| 105 |
+
seal_diameter = 160
|
| 106 |
+
seal = Image.new("RGBA", (seal_diameter, seal_diameter), (255, 255, 255, 0))
|
| 107 |
+
seal_draw = ImageDraw.Draw(seal)
|
| 108 |
+
|
| 109 |
+
center = seal_diameter // 2
|
| 110 |
+
|
| 111 |
+
# Outer thick ring
|
| 112 |
+
seal_draw.ellipse(
|
| 113 |
+
[(5, 5), (seal_diameter - 5, seal_diameter - 5)],
|
| 114 |
+
outline=(0, 51, 102, 255), width=8
|
| 115 |
+
)
|
| 116 |
+
|
| 117 |
+
# Inner thin ring
|
| 118 |
+
seal_draw.ellipse(
|
| 119 |
+
[(20, 20), (seal_diameter - 20, seal_diameter - 20)],
|
| 120 |
+
outline=(0, 102, 204, 255), width=3
|
| 121 |
+
)
|
| 122 |
+
|
| 123 |
+
# Radial lines for decoration
|
| 124 |
+
num_rays = 24
|
| 125 |
+
for i in range(num_rays):
|
| 126 |
+
angle = (360 / num_rays) * i
|
| 127 |
+
start_x = center + int((seal_diameter//2 - 20) * math.cos(math.radians(angle)))
|
| 128 |
+
start_y = center + int((seal_diameter//2 - 20) * math.sin(math.radians(angle)))
|
| 129 |
+
end_x = center + int((seal_diameter//2 - 5) * math.cos(math.radians(angle)))
|
| 130 |
+
end_y = center + int((seal_diameter//2 - 5) * math.sin(math.radians(angle)))
|
| 131 |
+
seal_draw.line([(start_x, start_y), (end_x, end_y)], fill=(0, 51, 102, 180), width=2)
|
| 132 |
+
|
| 133 |
+
# Paste resized logo in center if available
|
| 134 |
+
if logo:
|
| 135 |
+
max_logo_size = seal_diameter - 60 # حدود 100x100
|
| 136 |
+
logo = logo.resize((max_logo_size, max_logo_size), Image.Resampling.LANCZOS)
|
| 137 |
+
logo_pos = (center - max_logo_size // 2, center - max_logo_size // 2)
|
| 138 |
+
seal.paste(logo, logo_pos, logo)
|
| 139 |
+
|
| 140 |
+
# Center text below logo (اختیاری)
|
| 141 |
+
center_text = "Official Seal"
|
| 142 |
+
bbox = seal_draw.textbbox((0, 0), center_text, font=font_small)
|
| 143 |
+
w = bbox[2] - bbox[0]
|
| 144 |
+
h = bbox[3] - bbox[1]
|
| 145 |
+
seal_draw.text(((seal_diameter - w)//2, seal_diameter - h - 15), center_text, font=font_small, fill=(0, 51, 102, 200))
|
| 146 |
+
|
| 147 |
+
# Paste seal on top right corner of certificate
|
| 148 |
+
certificate.paste(seal, (width - seal_diameter - 40, 40), seal)
|
| 149 |
+
|
| 150 |
+
# Save certificate image
|
| 151 |
+
certificate.save("openai_certificate_yasin_en_2.png")
|
| 152 |
+
print("✅ Certificate image created: openai_certificate_yasin_en_2.png")
|
cert/cert6.py
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from PIL import Image, ImageDraw, ImageFont
|
| 2 |
+
import math
|
| 3 |
+
import qrcode
|
| 4 |
+
import hashlib
|
| 5 |
+
|
| 6 |
+
# ===== Certificate Info =====
|
| 7 |
+
name = "Yasin"
|
| 8 |
+
user_id = "YSNRFD"
|
| 9 |
+
membership_date = "April 1, 2023"
|
| 10 |
+
issued_date = "June 28, 2025"
|
| 11 |
+
certificate_id = "OPENAI-YSN-APR2023-CERT1001"
|
| 12 |
+
signed_by = "ChatGPT-4o"
|
| 13 |
+
model_id = "GPT4O-REP-TRUST-2025"
|
| 14 |
+
issuer = "OpenAI, Inc."
|
| 15 |
+
|
| 16 |
+
data_string = f"""
|
| 17 |
+
Name: {name}
|
| 18 |
+
User ID: {user_id}
|
| 19 |
+
Membership Date: {membership_date}
|
| 20 |
+
Issued Date: {issued_date}
|
| 21 |
+
Certificate ID: {certificate_id}
|
| 22 |
+
Signed By: {signed_by}
|
| 23 |
+
Model ID: {model_id}
|
| 24 |
+
Issuer: {issuer}
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
digital_signature = hashlib.sha256(data_string.encode('utf-8')).hexdigest()
|
| 28 |
+
verification_code = f"VER-{digital_signature[:8].upper()}-{certificate_id[-4:]}"
|
| 29 |
+
|
| 30 |
+
qr = qrcode.QRCode(box_size=7, border=3)
|
| 31 |
+
qr.add_data(digital_signature)
|
| 32 |
+
qr.make(fit=True)
|
| 33 |
+
qr_img = qr.make_image(fill_color="black", back_color="white").convert("RGBA")
|
| 34 |
+
|
| 35 |
+
try:
|
| 36 |
+
font_title = ImageFont.truetype("arialbd.ttf", 30)
|
| 37 |
+
font_header = ImageFont.truetype("arialbd.ttf", 18)
|
| 38 |
+
font_text = ImageFont.truetype("arial.ttf", 16)
|
| 39 |
+
font_small = ImageFont.truetype("arial.ttf", 14)
|
| 40 |
+
except:
|
| 41 |
+
font_title = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 30)
|
| 42 |
+
font_header = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 18)
|
| 43 |
+
font_text = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 16)
|
| 44 |
+
font_small = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 14)
|
| 45 |
+
|
| 46 |
+
width, height = 850, 520
|
| 47 |
+
certificate = Image.new("RGB", (width, height), "#fffefa")
|
| 48 |
+
draw = ImageDraw.Draw(certificate)
|
| 49 |
+
|
| 50 |
+
draw.rectangle([(15, 15), (width-15, height-15)], outline="#555555", width=3)
|
| 51 |
+
draw.line([(20, 80), (width-20, 80)], fill="#999999", width=2)
|
| 52 |
+
|
| 53 |
+
draw.text((40, 30), "OpenAI – Certificate of Membership", font=font_title, fill="#222222")
|
| 54 |
+
|
| 55 |
+
info_lines = [
|
| 56 |
+
f"Name: {name}",
|
| 57 |
+
f"User ID: {user_id}",
|
| 58 |
+
f"Membership Date: {membership_date}",
|
| 59 |
+
f"Issued Date: {issued_date}",
|
| 60 |
+
f"Certificate ID: {certificate_id}",
|
| 61 |
+
f"Signed By: {signed_by}",
|
| 62 |
+
f"Model ID: {model_id}",
|
| 63 |
+
f"Issuer: {issuer}",
|
| 64 |
+
]
|
| 65 |
+
|
| 66 |
+
y_text = 100
|
| 67 |
+
for line in info_lines:
|
| 68 |
+
draw.text((40, y_text), line, font=font_text, fill="#333333")
|
| 69 |
+
y_text += 30
|
| 70 |
+
|
| 71 |
+
draw.text((40, y_text + 10), f"Verification Code: {verification_code}", font=font_header, fill="#444444")
|
| 72 |
+
|
| 73 |
+
draw.text((40, y_text + 50), "SHA-256 Digital Signature:", font=font_header, fill="#222222")
|
| 74 |
+
|
| 75 |
+
sig_1 = digital_signature[:len(digital_signature)//2]
|
| 76 |
+
sig_2 = digital_signature[len(digital_signature)//2:]
|
| 77 |
+
draw.text((40, y_text + 80), sig_1, font=font_small, fill="#555555")
|
| 78 |
+
draw.text((40, y_text + 100), sig_2, font=font_small, fill="#555555")
|
| 79 |
+
|
| 80 |
+
qr_size = 150
|
| 81 |
+
qr_position = (width - qr_size - 40, height - qr_size - 40)
|
| 82 |
+
qr_img = qr_img.resize((qr_size, qr_size), Image.Resampling.LANCZOS)
|
| 83 |
+
certificate.paste(qr_img, qr_position, qr_img)
|
| 84 |
+
|
| 85 |
+
# -- Seal with hidden texts --
|
| 86 |
+
seal_diameter = 160
|
| 87 |
+
seal = Image.new("RGBA", (seal_diameter, seal_diameter), (255,255,255,0))
|
| 88 |
+
seal_draw = ImageDraw.Draw(seal)
|
| 89 |
+
center = seal_diameter // 2
|
| 90 |
+
|
| 91 |
+
# Outer and inner rings
|
| 92 |
+
seal_draw.ellipse([(5,5), (seal_diameter-5, seal_diameter-5)], outline=(0,51,102,255), width=8)
|
| 93 |
+
seal_draw.ellipse([(20,20), (seal_diameter-20, seal_diameter-20)], outline=(0,102,204,255), width=3)
|
| 94 |
+
|
| 95 |
+
# Radial lines
|
| 96 |
+
num_rays = 24
|
| 97 |
+
for i in range(num_rays):
|
| 98 |
+
angle = (360 / num_rays) * i
|
| 99 |
+
sx = center + int((seal_diameter//2 - 20) * math.cos(math.radians(angle)))
|
| 100 |
+
sy = center + int((seal_diameter//2 - 20) * math.sin(math.radians(angle)))
|
| 101 |
+
ex = center + int((seal_diameter//2 - 5) * math.cos(math.radians(angle)))
|
| 102 |
+
ey = center + int((seal_diameter//2 - 5) * math.sin(math.radians(angle)))
|
| 103 |
+
seal_draw.line([(sx, sy), (ex, ey)], fill=(0,51,102,180), width=2)
|
| 104 |
+
|
| 105 |
+
# Hidden secret texts in very small font around circle (like watermark)
|
| 106 |
+
hidden_texts = [
|
| 107 |
+
"CONFIDENTIAL", "AUTHORIZED", "OFFICIAL USE ONLY",
|
| 108 |
+
"SERIAL#:" + certificate_id[-6:],
|
| 109 |
+
"DIGITAL SIGNATURE VERIFIED",
|
| 110 |
+
"OPENAI SECURE SEAL",
|
| 111 |
+
"AUTHORIZED PERSONNEL ONLY",
|
| 112 |
+
"SECURE TRANSACTION",
|
| 113 |
+
"DO NOT COPY", "VALIDATED", "REGISTERED",
|
| 114 |
+
]
|
| 115 |
+
|
| 116 |
+
hidden_font = font_small
|
| 117 |
+
radius_hidden = seal_diameter//2 - 12
|
| 118 |
+
num_hidden = len(hidden_texts)
|
| 119 |
+
angle_start = 0
|
| 120 |
+
|
| 121 |
+
for i, txt in enumerate(hidden_texts):
|
| 122 |
+
angle = angle_start + (360 / num_hidden) * i
|
| 123 |
+
x = center + int(radius_hidden * math.cos(math.radians(angle)))
|
| 124 |
+
y = center + int(radius_hidden * math.sin(math.radians(angle)))
|
| 125 |
+
# بسیار ریز و کمرنگ
|
| 126 |
+
seal_draw.text((x-15, y-7), txt, font=hidden_font, fill=(0,0,0,40))
|
| 127 |
+
|
| 128 |
+
# Center text
|
| 129 |
+
center_text = "Official Seal"
|
| 130 |
+
bbox = seal_draw.textbbox((0,0), center_text, font=font_small)
|
| 131 |
+
w = bbox[2] - bbox[0]
|
| 132 |
+
h = bbox[3] - bbox[1]
|
| 133 |
+
seal_draw.text(((seal_diameter - w)//2, seal_diameter - h - 15), center_text, font=font_small, fill=(0,51,102,200))
|
| 134 |
+
|
| 135 |
+
# Paste seal on top right corner
|
| 136 |
+
certificate.paste(seal, (width - seal_diameter - 40, 40), seal)
|
| 137 |
+
|
| 138 |
+
# Save final image
|
| 139 |
+
certificate.save("openai_certificate_with_hidden_texts.png")
|
| 140 |
+
print("✅ Certificate image created with hidden seal texts: openai_certificate_with_hidden_texts.png")
|
cert/cert7.py
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from PIL import Image, ImageDraw, ImageFont
|
| 2 |
+
import math
|
| 3 |
+
import qrcode
|
| 4 |
+
import hashlib
|
| 5 |
+
import random
|
| 6 |
+
|
| 7 |
+
# ===== Certificate Info =====
|
| 8 |
+
name = "Yasin"
|
| 9 |
+
user_id = "YSNRFD"
|
| 10 |
+
membership_date = "April 1, 2023"
|
| 11 |
+
issued_date = "June 28, 2025"
|
| 12 |
+
certificate_id = "OPENAI-YSN-APR2023-CERT1001"
|
| 13 |
+
signed_by = "ChatGPT-4o"
|
| 14 |
+
model_id = "GPT4O-REP-TRUST-2025"
|
| 15 |
+
issuer = "OpenAI, Inc."
|
| 16 |
+
|
| 17 |
+
# Prepare data string for digital signature
|
| 18 |
+
data_string = f"""
|
| 19 |
+
Name: {name}
|
| 20 |
+
User ID: {user_id}
|
| 21 |
+
Membership Date: {membership_date}
|
| 22 |
+
Issued Date: {issued_date}
|
| 23 |
+
Certificate ID: {certificate_id}
|
| 24 |
+
Signed By: {signed_by}
|
| 25 |
+
Model ID: {model_id}
|
| 26 |
+
Issuer: {issuer}
|
| 27 |
+
"""
|
| 28 |
+
|
| 29 |
+
# Generate SHA-256 digital signature
|
| 30 |
+
digital_signature = hashlib.sha256(data_string.encode('utf-8')).hexdigest()
|
| 31 |
+
verification_code = f"VER-{digital_signature[:8].upper()}-{certificate_id[-4:]}"
|
| 32 |
+
|
| 33 |
+
# Create QR code from digital signature
|
| 34 |
+
qr = qrcode.QRCode(box_size=7, border=3)
|
| 35 |
+
qr.add_data(digital_signature)
|
| 36 |
+
qr.make(fit=True)
|
| 37 |
+
qr_img = qr.make_image(fill_color="black", back_color="white").convert("RGBA")
|
| 38 |
+
|
| 39 |
+
# Load fonts with fallback
|
| 40 |
+
try:
|
| 41 |
+
font_title = ImageFont.truetype("arialbd.ttf", 30)
|
| 42 |
+
font_header = ImageFont.truetype("arialbd.ttf", 18)
|
| 43 |
+
font_text = ImageFont.truetype("arial.ttf", 16)
|
| 44 |
+
font_small = ImageFont.truetype("arial.ttf", 14)
|
| 45 |
+
except:
|
| 46 |
+
font_title = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 30)
|
| 47 |
+
font_header = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 18)
|
| 48 |
+
font_text = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 16)
|
| 49 |
+
font_small = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 14)
|
| 50 |
+
|
| 51 |
+
# Create certificate canvas
|
| 52 |
+
width, height = 850, 520
|
| 53 |
+
certificate = Image.new("RGB", (width, height), "#fffefa")
|
| 54 |
+
draw = ImageDraw.Draw(certificate)
|
| 55 |
+
|
| 56 |
+
# Background rectangle and divider line
|
| 57 |
+
draw.rectangle([(15, 15), (width-15, height-15)], outline="#555555", width=3)
|
| 58 |
+
draw.line([(20, 80), (width-20, 80)], fill="#999999", width=2)
|
| 59 |
+
|
| 60 |
+
# Title text
|
| 61 |
+
draw.text((40, 30), "OpenAI – Certificate of Membership", font=font_title, fill="#222222")
|
| 62 |
+
|
| 63 |
+
# Certificate info lines
|
| 64 |
+
info_lines = [
|
| 65 |
+
f"Name: {name}",
|
| 66 |
+
f"User ID: {user_id}",
|
| 67 |
+
f"Membership Date: {membership_date}",
|
| 68 |
+
f"Issued Date: {issued_date}",
|
| 69 |
+
f"Certificate ID: {certificate_id}",
|
| 70 |
+
f"Signed By: {signed_by}",
|
| 71 |
+
f"Model ID: {model_id}",
|
| 72 |
+
f"Issuer: {issuer}",
|
| 73 |
+
]
|
| 74 |
+
|
| 75 |
+
y_text = 100
|
| 76 |
+
for line in info_lines:
|
| 77 |
+
draw.text((40, y_text), line, font=font_text, fill="#333333")
|
| 78 |
+
y_text += 30
|
| 79 |
+
|
| 80 |
+
# Verification code
|
| 81 |
+
draw.text((40, y_text + 10), f"Verification Code: {verification_code}", font=font_header, fill="#444444")
|
| 82 |
+
|
| 83 |
+
# Digital signature label and text
|
| 84 |
+
draw.text((40, y_text + 50), "SHA-256 Digital Signature:", font=font_header, fill="#222222")
|
| 85 |
+
|
| 86 |
+
sig_1 = digital_signature[:len(digital_signature)//2]
|
| 87 |
+
sig_2 = digital_signature[len(digital_signature)//2:]
|
| 88 |
+
draw.text((40, y_text + 80), sig_1, font=font_small, fill="#555555")
|
| 89 |
+
draw.text((40, y_text + 100), sig_2, font=font_small, fill="#555555")
|
| 90 |
+
|
| 91 |
+
# Paste QR code on bottom right
|
| 92 |
+
qr_size = 150
|
| 93 |
+
qr_position = (width - qr_size - 40, height - qr_size - 40)
|
| 94 |
+
qr_img = qr_img.resize((qr_size, qr_size), Image.Resampling.LANCZOS)
|
| 95 |
+
certificate.paste(qr_img, qr_position, qr_img)
|
| 96 |
+
|
| 97 |
+
# ==== Draw a professional OpenAI seal with logo inside ====
|
| 98 |
+
|
| 99 |
+
try:
|
| 100 |
+
logo = Image.open("openai_seal.png").convert("RGBA")
|
| 101 |
+
except FileNotFoundError:
|
| 102 |
+
print("⚠️ فایل لوگوی openai_seal.png پیدا نشد! لطفا لوگوی مناسب کنار اسکریپت قرار دهید.")
|
| 103 |
+
logo = None
|
| 104 |
+
|
| 105 |
+
seal_diameter = 160
|
| 106 |
+
seal = Image.new("RGBA", (seal_diameter, seal_diameter), (255, 255, 255, 0))
|
| 107 |
+
seal_draw = ImageDraw.Draw(seal)
|
| 108 |
+
center = seal_diameter // 2
|
| 109 |
+
|
| 110 |
+
# Outer thick ring
|
| 111 |
+
seal_draw.ellipse(
|
| 112 |
+
[(5, 5), (seal_diameter - 5, seal_diameter - 5)],
|
| 113 |
+
outline=(0, 51, 102, 255), width=8
|
| 114 |
+
)
|
| 115 |
+
|
| 116 |
+
# Inner thin ring
|
| 117 |
+
seal_draw.ellipse(
|
| 118 |
+
[(20, 20), (seal_diameter - 20, seal_diameter - 20)],
|
| 119 |
+
outline=(0, 102, 204, 255), width=3
|
| 120 |
+
)
|
| 121 |
+
|
| 122 |
+
# Radial lines for decoration
|
| 123 |
+
num_rays = 24
|
| 124 |
+
for i in range(num_rays):
|
| 125 |
+
angle = (360 / num_rays) * i
|
| 126 |
+
start_x = center + int((seal_diameter//2 - 20) * math.cos(math.radians(angle)))
|
| 127 |
+
start_y = center + int((seal_diameter//2 - 20) * math.sin(math.radians(angle)))
|
| 128 |
+
end_x = center + int((seal_diameter//2 - 5) * math.cos(math.radians(angle)))
|
| 129 |
+
end_y = center + int((seal_diameter//2 - 5) * math.sin(math.radians(angle)))
|
| 130 |
+
seal_draw.line([(start_x, start_y), (end_x, end_y)], fill=(0, 51, 102, 180), width=2)
|
| 131 |
+
|
| 132 |
+
# Paste resized logo in center if available
|
| 133 |
+
if logo:
|
| 134 |
+
max_logo_size = seal_diameter - 60 # حدود 100x100
|
| 135 |
+
logo = logo.resize((max_logo_size, max_logo_size), Image.Resampling.LANCZOS)
|
| 136 |
+
logo_pos = (center - max_logo_size // 2, center - max_logo_size // 2)
|
| 137 |
+
seal.paste(logo, logo_pos, logo)
|
| 138 |
+
|
| 139 |
+
# Center text below logo (اختیاری)
|
| 140 |
+
center_text = "Official Seal"
|
| 141 |
+
bbox = seal_draw.textbbox((0, 0), center_text, font=font_small)
|
| 142 |
+
w = bbox[2] - bbox[0]
|
| 143 |
+
h = bbox[3] - bbox[1]
|
| 144 |
+
seal_draw.text(((seal_diameter - w)//2, seal_diameter - h - 15), center_text, font=font_small, fill=(0, 51, 102, 200))
|
| 145 |
+
|
| 146 |
+
# Paste seal on top right corner of certificate
|
| 147 |
+
certificate.paste(seal, (width - seal_diameter - 40, 40), seal)
|
| 148 |
+
|
| 149 |
+
# ==== Add subtle invisible watermark text scattered ====
|
| 150 |
+
|
| 151 |
+
watermark_texts = [
|
| 152 |
+
"AUTHORIZED", "CONFIDENTIAL", "OFFICIAL_USE_ONLY", "SECURE",
|
| 153 |
+
certificate_id, digital_signature[:16], verification_code,
|
| 154 |
+
"VALIDATED", "NO_COPY", "OPENAI"
|
| 155 |
+
]
|
| 156 |
+
|
| 157 |
+
wm_font = font_small
|
| 158 |
+
|
| 159 |
+
for _ in range(50):
|
| 160 |
+
text = random.choice(watermark_texts)
|
| 161 |
+
# Random position over whole certificate
|
| 162 |
+
x = random.randint(0, width-100)
|
| 163 |
+
y = random.randint(0, height-20)
|
| 164 |
+
# Very faint gray with opacity 30 (almost invisible)
|
| 165 |
+
alpha = 20
|
| 166 |
+
color = (50, 50, 50, alpha)
|
| 167 |
+
|
| 168 |
+
# Create transparent text image
|
| 169 |
+
txt_img = Image.new("RGBA", (150, 20), (255, 255, 255, 0))
|
| 170 |
+
txt_draw = ImageDraw.Draw(txt_img)
|
| 171 |
+
txt_draw.text((0, 0), text, font=wm_font, fill=color)
|
| 172 |
+
# Rotate text randomly small angle
|
| 173 |
+
angle = random.uniform(-15, 15)
|
| 174 |
+
txt_img = txt_img.rotate(angle, expand=1)
|
| 175 |
+
|
| 176 |
+
# Paste watermark text on certificate (with transparency mask)
|
| 177 |
+
certificate.paste(txt_img, (x, y), txt_img)
|
| 178 |
+
|
| 179 |
+
# ==== Add subtle pixel noise for anti-forgery ====
|
| 180 |
+
|
| 181 |
+
pixels = certificate.load()
|
| 182 |
+
for _ in range(800): # Number of pixels to modify
|
| 183 |
+
px = random.randint(0, width-1)
|
| 184 |
+
py = random.randint(0, height-1)
|
| 185 |
+
r, g, b = pixels[px, py]
|
| 186 |
+
# Slight noise, add or subtract 1 to 3 from each channel randomly within bounds 0-255
|
| 187 |
+
r = max(0, min(255, r + random.randint(-3, 3)))
|
| 188 |
+
g = max(0, min(255, g + random.randint(-3, 3)))
|
| 189 |
+
b = max(0, min(255, b + random.randint(-3, 3)))
|
| 190 |
+
pixels[px, py] = (r, g, b)
|
| 191 |
+
|
| 192 |
+
# Save certificate image
|
| 193 |
+
certificate.save("openai_certificate_yasin_en_2_watermarked.png")
|
| 194 |
+
print("✅ Certificate image created with hidden watermark and noise: openai_certificate_yasin_en_2_watermarked.png")
|
cert/cert8.py
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from PIL import Image, ImageDraw, ImageFont, ImageFilter, ImageEnhance
|
| 2 |
+
import qrcode
|
| 3 |
+
import hashlib
|
| 4 |
+
import random
|
| 5 |
+
import math
|
| 6 |
+
import os
|
| 7 |
+
|
| 8 |
+
# ======== تنظیمات قابل تغییر ========
|
| 9 |
+
CERT_WIDTH, CERT_HEIGHT = 900, 550
|
| 10 |
+
MARGIN = 30
|
| 11 |
+
BACKGROUND_COLOR = (255, 255, 250)
|
| 12 |
+
BORDER_COLOR = (60, 60, 60)
|
| 13 |
+
TITLE_COLOR = (20, 20, 20)
|
| 14 |
+
TEXT_COLOR = (40, 40, 40)
|
| 15 |
+
WATERMARK_COLOR = (60, 60, 60, 25) # با آلفای کم
|
| 16 |
+
NOISE_INTENSITY = 1200 # تعداد پیکسل نویز
|
| 17 |
+
|
| 18 |
+
# ======== اطلاعات گواهی ========
|
| 19 |
+
cert_info = {
|
| 20 |
+
"Name": "Yasin",
|
| 21 |
+
"User ID": "YSNRFD",
|
| 22 |
+
"Membership Date": "April 1, 2023",
|
| 23 |
+
"Issued Date": "June 28, 2025",
|
| 24 |
+
"Certificate ID": "OPENAI-YSN-APR2023-CERT1001",
|
| 25 |
+
"Signed By": "ChatGPT-4o",
|
| 26 |
+
"Model ID": "GPT4O-REP-TRUST-2025",
|
| 27 |
+
"Issuer": "OpenAI, Inc."
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
# ======== تابع بارگذاری فونت پویا با fallback ========
|
| 31 |
+
def load_font(name, size):
|
| 32 |
+
paths = [
|
| 33 |
+
name,
|
| 34 |
+
os.path.join("/usr/share/fonts/truetype/dejavu/", name),
|
| 35 |
+
os.path.join("/Library/Fonts/", name),
|
| 36 |
+
os.path.join("C:/Windows/Fonts/", name)
|
| 37 |
+
]
|
| 38 |
+
for path in paths:
|
| 39 |
+
try:
|
| 40 |
+
return ImageFont.truetype(path, size)
|
| 41 |
+
except:
|
| 42 |
+
continue
|
| 43 |
+
# فونت پیشفرض PIL
|
| 44 |
+
return ImageFont.load_default()
|
| 45 |
+
|
| 46 |
+
# فونتها
|
| 47 |
+
font_title = load_font("arialbd.ttf", 36)
|
| 48 |
+
font_header = load_font("arialbd.ttf", 20)
|
| 49 |
+
font_text = load_font("arial.ttf", 18)
|
| 50 |
+
font_small = load_font("arial.ttf", 14)
|
| 51 |
+
|
| 52 |
+
# ======== تولید رشته داده برای امضا دیجیتال ========
|
| 53 |
+
data_string = "\n".join(f"{k}: {v}" for k, v in cert_info.items())
|
| 54 |
+
digital_signature = hashlib.sha256(data_string.encode('utf-8')).hexdigest()
|
| 55 |
+
verification_code = f"VER-{digital_signature[:8].upper()}-{cert_info['Certificate ID'][-4:]}"
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
# ======== ایجاد QR code به صورت با کیفیت و رنگ سفارشی ========
|
| 59 |
+
def create_qr_code(data, size=180):
|
| 60 |
+
qr = qrcode.QRCode(box_size=8, border=3)
|
| 61 |
+
qr.add_data(data)
|
| 62 |
+
qr.make(fit=True)
|
| 63 |
+
qr_img = qr.make_image(fill_color="#003366", back_color="white").convert("RGBA")
|
| 64 |
+
qr_img = qr_img.resize((size, size), Image.Resampling.LANCZOS)
|
| 65 |
+
return qr_img
|
| 66 |
+
|
| 67 |
+
qr_img = create_qr_code(digital_signature, size=180)
|
| 68 |
+
|
| 69 |
+
# ======== طراحی پسزمینه با گرادیانت ملایم ========
|
| 70 |
+
def draw_gradient(draw, width, height, start_color, end_color):
|
| 71 |
+
for i in range(height):
|
| 72 |
+
r = int(start_color[0] + (float(i) / height) * (end_color[0] - start_color[0]))
|
| 73 |
+
g = int(start_color[1] + (float(i) / height) * (end_color[1] - start_color[1]))
|
| 74 |
+
b = int(start_color[2] + (float(i) / height) * (end_color[2] - start_color[2]))
|
| 75 |
+
draw.line([(0, i), (width, i)], fill=(r, g, b))
|
| 76 |
+
|
| 77 |
+
# ======== رسم مهر رسمی با افکت سهبعدی ========
|
| 78 |
+
def create_official_seal(diameter=160):
|
| 79 |
+
seal = Image.new("RGBA", (diameter, diameter), (0, 0, 0, 0))
|
| 80 |
+
draw = ImageDraw.Draw(seal)
|
| 81 |
+
center = diameter // 2
|
| 82 |
+
|
| 83 |
+
# حلقه بیرونی با گرادیانت شعاعی
|
| 84 |
+
for i in range(8):
|
| 85 |
+
alpha = int(255 * (1 - i/8))
|
| 86 |
+
radius = center - i*6
|
| 87 |
+
draw.ellipse(
|
| 88 |
+
[(center - radius, center - radius), (center + radius, center + radius)],
|
| 89 |
+
outline=(0, 51, 102, alpha),
|
| 90 |
+
width=3
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
# خطوط شعاعی تزئینی
|
| 94 |
+
num_rays = 28
|
| 95 |
+
outer_r = center - 15
|
| 96 |
+
inner_r = center - 45
|
| 97 |
+
for i in range(num_rays):
|
| 98 |
+
angle = 360 / num_rays * i
|
| 99 |
+
x1 = center + int(inner_r * math.cos(math.radians(angle)))
|
| 100 |
+
y1 = center + int(inner_r * math.sin(math.radians(angle)))
|
| 101 |
+
x2 = center + int(outer_r * math.cos(math.radians(angle)))
|
| 102 |
+
y2 = center + int(outer_r * math.sin(math.radians(angle)))
|
| 103 |
+
draw.line([(x1, y1), (x2, y2)], fill=(0, 51, 102, 180), width=2)
|
| 104 |
+
|
| 105 |
+
# قرار دادن لوگوی openai_seal.png در وسط مهر
|
| 106 |
+
try:
|
| 107 |
+
logo = Image.open("openai_seal.png").convert("RGBA")
|
| 108 |
+
max_logo_size = diameter - 90 # حدود 70x70 یا کمی بزرگتر
|
| 109 |
+
logo.thumbnail((max_logo_size, max_logo_size), Image.Resampling.LANCZOS)
|
| 110 |
+
logo_pos = (center - logo.width // 2, center - logo.height // 2)
|
| 111 |
+
seal.paste(logo, logo_pos, logo)
|
| 112 |
+
except FileNotFoundError:
|
| 113 |
+
print("⚠️ فایل openai_seal.png پیدا نشد! مهر بدون لوگو ساخته شد.")
|
| 114 |
+
|
| 115 |
+
# متن مهر دایرهای
|
| 116 |
+
seal_text = "OFFICIAL OPENAI SEAL"
|
| 117 |
+
font_circle = load_font("arialbd.ttf", 16)
|
| 118 |
+
radius_text = center - 12
|
| 119 |
+
|
| 120 |
+
for i, char in enumerate(seal_text):
|
| 121 |
+
angle_deg = (360 / len(seal_text)) * i - 90
|
| 122 |
+
angle_rad = math.radians(angle_deg)
|
| 123 |
+
x = center + int(radius_text * math.cos(angle_rad))
|
| 124 |
+
y = center + int(radius_text * math.sin(angle_rad))
|
| 125 |
+
draw.text((x-8, y-8), char, font=font_circle, fill=(0, 51, 102, 220))
|
| 126 |
+
|
| 127 |
+
# سایه ملایم برای زیبایی
|
| 128 |
+
seal = seal.filter(ImageFilter.GaussianBlur(radius=0.5))
|
| 129 |
+
|
| 130 |
+
return seal
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
official_seal = create_official_seal()
|
| 134 |
+
|
| 135 |
+
# ======== ایجاد تصویر گواهی ========
|
| 136 |
+
certificate = Image.new("RGBA", (CERT_WIDTH, CERT_HEIGHT), BACKGROUND_COLOR)
|
| 137 |
+
draw = ImageDraw.Draw(certificate)
|
| 138 |
+
|
| 139 |
+
# گرادیانت پس زمینه ملایم
|
| 140 |
+
draw_gradient(draw, CERT_WIDTH, CERT_HEIGHT, (255, 255, 250), (230, 240, 255))
|
| 141 |
+
|
| 142 |
+
# قاب حاشیهای چند لایه
|
| 143 |
+
for i, thickness in enumerate([6, 4, 2]):
|
| 144 |
+
color_val = 80 - i * 20
|
| 145 |
+
draw.rectangle(
|
| 146 |
+
[MARGIN - i*2, MARGIN - i*2, CERT_WIDTH - MARGIN + i*2, CERT_HEIGHT - MARGIN + i*2],
|
| 147 |
+
outline=(color_val, color_val, color_val)
|
| 148 |
+
)
|
| 149 |
+
|
| 150 |
+
# عنوان اصلی
|
| 151 |
+
title_text = "OpenAI – Certificate of Membership"
|
| 152 |
+
bbox = draw.textbbox((0, 0), title_text, font=font_title)
|
| 153 |
+
w = bbox[2] - bbox[0]
|
| 154 |
+
h = bbox[3] - bbox[1]
|
| 155 |
+
draw.text(((CERT_WIDTH - w) / 2, MARGIN + 10), title_text, fill=TITLE_COLOR, font=font_title)
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
# خط جداکننده زیبا
|
| 159 |
+
line_y = MARGIN + h + 30
|
| 160 |
+
draw.line([(MARGIN + 10, line_y), (CERT_WIDTH - MARGIN - 10, line_y)], fill=(100, 100, 120), width=3)
|
| 161 |
+
|
| 162 |
+
# نوشتن اطلاعات گواهی
|
| 163 |
+
info_x = MARGIN + 30
|
| 164 |
+
info_y = line_y + 20
|
| 165 |
+
line_spacing = 36
|
| 166 |
+
|
| 167 |
+
for key, val in cert_info.items():
|
| 168 |
+
text_line = f"{key}: {val}"
|
| 169 |
+
draw.text((info_x, info_y), text_line, font=font_text, fill=TEXT_COLOR)
|
| 170 |
+
info_y += line_spacing
|
| 171 |
+
|
| 172 |
+
# کد تایید اعتبار
|
| 173 |
+
verification_label = "Verification Code:"
|
| 174 |
+
verification_text = verification_code
|
| 175 |
+
info_y += 20
|
| 176 |
+
draw.text((info_x, info_y), verification_label, font=font_header, fill=TEXT_COLOR)
|
| 177 |
+
draw.text((info_x + 190, info_y), verification_text, font=font_header, fill=(0, 70, 120))
|
| 178 |
+
|
| 179 |
+
# متن امضای دیجیتال (شکسته به دو خط)
|
| 180 |
+
sig_half = len(digital_signature) // 2
|
| 181 |
+
sig_1 = digital_signature[:sig_half]
|
| 182 |
+
sig_2 = digital_signature[sig_half:]
|
| 183 |
+
draw.text((info_x, info_y + 40), sig_1, font=font_small, fill=(100, 100, 120))
|
| 184 |
+
draw.text((info_x, info_y + 60), sig_2, font=font_small, fill=(100, 100, 120))
|
| 185 |
+
|
| 186 |
+
# قرار دادن QR Code در پایین سمت راست
|
| 187 |
+
qr_pos = (CERT_WIDTH - qr_img.width - MARGIN - 20, CERT_HEIGHT - qr_img.height - MARGIN - 20)
|
| 188 |
+
certificate.paste(qr_img, qr_pos, qr_img)
|
| 189 |
+
|
| 190 |
+
# قرار دادن مهر رسمی در گوشه بالا سمت راست
|
| 191 |
+
seal_pos = (CERT_WIDTH - official_seal.width - MARGIN - 20, MARGIN + 10)
|
| 192 |
+
certificate.paste(official_seal, seal_pos, official_seal)
|
| 193 |
+
|
| 194 |
+
# ======== اضافه کردن واترمارک نامرئی ========
|
| 195 |
+
watermarks = [
|
| 196 |
+
"AUTHORIZED", "CONFIDENTIAL", "OFFICIAL_USE_ONLY", "SECURE",
|
| 197 |
+
cert_info["Certificate ID"], digital_signature[:16], verification_code,
|
| 198 |
+
"VALIDATED", "NO_COPY", "OPENAI"
|
| 199 |
+
]
|
| 200 |
+
|
| 201 |
+
for _ in range(60):
|
| 202 |
+
wm_text = random.choice(watermarks)
|
| 203 |
+
txt_img = Image.new("RGBA", (160, 20), (0, 0, 0, 0))
|
| 204 |
+
txt_draw = ImageDraw.Draw(txt_img)
|
| 205 |
+
txt_draw.text((0, 0), wm_text, font=font_small, fill=WATERMARK_COLOR)
|
| 206 |
+
angle = random.uniform(-20, 20)
|
| 207 |
+
txt_img = txt_img.rotate(angle, expand=1)
|
| 208 |
+
|
| 209 |
+
# موقعیت تصادفی اما دور از لبهها
|
| 210 |
+
x = random.randint(MARGIN + 10, CERT_WIDTH - 170)
|
| 211 |
+
y = random.randint(MARGIN + 10, CERT_HEIGHT - 30)
|
| 212 |
+
certificate.paste(txt_img, (x, y), txt_img)
|
| 213 |
+
|
| 214 |
+
# ======== اضافه کردن نویز پیکسلی برای ضد جعل ========
|
| 215 |
+
pixels = certificate.load()
|
| 216 |
+
for _ in range(NOISE_INTENSITY):
|
| 217 |
+
px = random.randint(0, CERT_WIDTH - 1)
|
| 218 |
+
py = random.randint(0, CERT_HEIGHT - 1)
|
| 219 |
+
r, g, b, a = pixels[px, py]
|
| 220 |
+
noise = random.randint(-5, 5)
|
| 221 |
+
r = max(0, min(255, r + noise))
|
| 222 |
+
g = max(0, min(255, g + noise))
|
| 223 |
+
b = max(0, min(255, b + noise))
|
| 224 |
+
pixels[px, py] = (r, g, b, a)
|
| 225 |
+
|
| 226 |
+
# ======== ذخیره فایل نهایی ========
|
| 227 |
+
output_file = "openai_certificate_yasin_professional.png"
|
| 228 |
+
certificate.convert("RGB").save(output_file, quality=95)
|
| 229 |
+
print(f"✅ Professional certificate created: {output_file}")
|
cert/cert9.py
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from PIL import Image, ImageDraw, ImageFont, ImageFilter, ImageEnhance
|
| 2 |
+
import qrcode
|
| 3 |
+
import hashlib
|
| 4 |
+
import random
|
| 5 |
+
import math
|
| 6 |
+
import os
|
| 7 |
+
|
| 8 |
+
# ======== تنظیمات قابل تغییر ========
|
| 9 |
+
CERT_WIDTH, CERT_HEIGHT = 900, 550
|
| 10 |
+
MARGIN = 30
|
| 11 |
+
BACKGROUND_COLOR = (255, 255, 250)
|
| 12 |
+
BORDER_COLOR = (60, 60, 60)
|
| 13 |
+
TITLE_COLOR = (20, 20, 20)
|
| 14 |
+
TEXT_COLOR = (40, 40, 40)
|
| 15 |
+
WATERMARK_COLOR = (60, 60, 60, 25) # با آلفای کم
|
| 16 |
+
NOISE_INTENSITY = 1200 # تعداد پیکسل نویز
|
| 17 |
+
|
| 18 |
+
# ======== اطلاعات گواهی ========
|
| 19 |
+
cert_info = {
|
| 20 |
+
"Name": "Yasin",
|
| 21 |
+
"User ID": "YSNRFD",
|
| 22 |
+
"Membership Date": "April 1, 2023",
|
| 23 |
+
"Issued Date": "June 28, 2025",
|
| 24 |
+
"Certificate ID": "OPENAI-YSN-APR2023-CERT1001",
|
| 25 |
+
"Signed By": "ChatGPT-4o",
|
| 26 |
+
"Model ID": "GPT4O-REP-TRUST-2025",
|
| 27 |
+
"Issuer": "OpenAI, Inc."
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
# ======== تابع بارگذاری فونت پویا با fallback ========
|
| 31 |
+
def load_font(name, size):
|
| 32 |
+
paths = [
|
| 33 |
+
name,
|
| 34 |
+
os.path.join("/usr/share/fonts/truetype/dejavu/", name),
|
| 35 |
+
os.path.join("/Library/Fonts/", name),
|
| 36 |
+
os.path.join("C:/Windows/Fonts/", name)
|
| 37 |
+
]
|
| 38 |
+
for path in paths:
|
| 39 |
+
try:
|
| 40 |
+
return ImageFont.truetype(path, size)
|
| 41 |
+
except:
|
| 42 |
+
continue
|
| 43 |
+
# فونت پیشفرض PIL
|
| 44 |
+
return ImageFont.load_default()
|
| 45 |
+
|
| 46 |
+
# فونتها
|
| 47 |
+
font_title = load_font("arialbd.ttf", 36)
|
| 48 |
+
font_header = load_font("arialbd.ttf", 20)
|
| 49 |
+
font_text = load_font("arial.ttf", 18)
|
| 50 |
+
font_small = load_font("arial.ttf", 14)
|
| 51 |
+
|
| 52 |
+
# ======== تولید رشته داده برای امضا دیجیتال ========
|
| 53 |
+
data_string = "\n".join(f"{k}: {v}" for k, v in cert_info.items())
|
| 54 |
+
digital_signature = hashlib.sha256(data_string.encode('utf-8')).hexdigest()
|
| 55 |
+
verification_code = f"VER-{digital_signature[:8].upper()}-{cert_info['Certificate ID'][-4:]}"
|
| 56 |
+
|
| 57 |
+
# ======== ایجاد QR code به صورت با کیفیت و رنگ سفارشی ========
|
| 58 |
+
def create_qr_code(data, size=180):
|
| 59 |
+
qr = qrcode.QRCode(box_size=8, border=3)
|
| 60 |
+
qr.add_data(data)
|
| 61 |
+
qr.make(fit=True)
|
| 62 |
+
qr_img = qr.make_image(fill_color="#003366", back_color="white").convert("RGBA")
|
| 63 |
+
qr_img = qr_img.resize((size, size), Image.Resampling.LANCZOS)
|
| 64 |
+
return qr_img
|
| 65 |
+
|
| 66 |
+
qr_img = create_qr_code(digital_signature, size=180)
|
| 67 |
+
|
| 68 |
+
# ======== طراحی پسزمینه با گرادیانت ملایم ========
|
| 69 |
+
def draw_gradient(draw, width, height, start_color, end_color):
|
| 70 |
+
for i in range(height):
|
| 71 |
+
r = int(start_color[0] + (float(i) / height) * (end_color[0] - start_color[0]))
|
| 72 |
+
g = int(start_color[1] + (float(i) / height) * (end_color[1] - start_color[1]))
|
| 73 |
+
b = int(start_color[2] + (float(i) / height) * (end_color[2] - start_color[2]))
|
| 74 |
+
draw.line([(0, i), (width, i)], fill=(r, g, b))
|
| 75 |
+
|
| 76 |
+
# ======== رسم مهر رسمی با افکت سهبعدی ========
|
| 77 |
+
def create_official_seal(diameter=160):
|
| 78 |
+
seal = Image.new("RGBA", (diameter, diameter), (0, 0, 0, 0))
|
| 79 |
+
draw = ImageDraw.Draw(seal)
|
| 80 |
+
center = diameter // 2
|
| 81 |
+
|
| 82 |
+
# حلقه بیرونی با گرادیانت شعاعی
|
| 83 |
+
for i in range(8):
|
| 84 |
+
alpha = int(255 * (1 - i/8))
|
| 85 |
+
radius = center - i*6
|
| 86 |
+
draw.ellipse(
|
| 87 |
+
[(center - radius, center - radius), (center + radius, center + radius)],
|
| 88 |
+
outline=(0, 51, 102, alpha),
|
| 89 |
+
width=3
|
| 90 |
+
)
|
| 91 |
+
|
| 92 |
+
# خطوط شعاعی تزئینی
|
| 93 |
+
num_rays = 28
|
| 94 |
+
outer_r = center - 15
|
| 95 |
+
inner_r = center - 45
|
| 96 |
+
for i in range(num_rays):
|
| 97 |
+
angle = 360 / num_rays * i
|
| 98 |
+
x1 = center + int(inner_r * math.cos(math.radians(angle)))
|
| 99 |
+
y1 = center + int(inner_r * math.sin(math.radians(angle)))
|
| 100 |
+
x2 = center + int(outer_r * math.cos(math.radians(angle)))
|
| 101 |
+
y2 = center + int(outer_r * math.sin(math.radians(angle)))
|
| 102 |
+
draw.line([(x1, y1), (x2, y2)], fill=(0, 51, 102, 180), width=2)
|
| 103 |
+
|
| 104 |
+
# قرار دادن لوگوی openai_seal.png در وسط مهر
|
| 105 |
+
try:
|
| 106 |
+
logo = Image.open("openai_seal.png").convert("RGBA")
|
| 107 |
+
max_logo_size = diameter - 90 # حدود 70x70 یا کمی بزرگتر
|
| 108 |
+
logo.thumbnail((max_logo_size, max_logo_size), Image.Resampling.LANCZOS)
|
| 109 |
+
logo_pos = (center - logo.width // 2, center - logo.height // 2)
|
| 110 |
+
seal.paste(logo, logo_pos, logo)
|
| 111 |
+
except FileNotFoundError:
|
| 112 |
+
print("⚠️ فایل openai_seal.png پیدا نشد! مهر بدون لوگو ساخته شد.")
|
| 113 |
+
|
| 114 |
+
# متن مهر دایرهای
|
| 115 |
+
seal_text = "OFFICIAL OPENAI SEAL"
|
| 116 |
+
font_circle = load_font("arialbd.ttf", 16)
|
| 117 |
+
radius_text = center - 12
|
| 118 |
+
|
| 119 |
+
for i, char in enumerate(seal_text):
|
| 120 |
+
angle_deg = (360 / len(seal_text)) * i - 90
|
| 121 |
+
angle_rad = math.radians(angle_deg)
|
| 122 |
+
x = center + int(radius_text * math.cos(angle_rad))
|
| 123 |
+
y = center + int(radius_text * math.sin(angle_rad))
|
| 124 |
+
draw.text((x-8, y-8), char, font=font_circle, fill=(0, 51, 102, 220))
|
| 125 |
+
|
| 126 |
+
# سایه ملایم برای زیبایی
|
| 127 |
+
seal = seal.filter(ImageFilter.GaussianBlur(radius=0.5))
|
| 128 |
+
|
| 129 |
+
return seal
|
| 130 |
+
|
| 131 |
+
official_seal = create_official_seal()
|
| 132 |
+
|
| 133 |
+
# ======== ایجاد تصویر گواهی ========
|
| 134 |
+
certificate = Image.new("RGBA", (CERT_WIDTH, CERT_HEIGHT), BACKGROUND_COLOR)
|
| 135 |
+
draw = ImageDraw.Draw(certificate)
|
| 136 |
+
|
| 137 |
+
# گرادیانت پس زمینه ملایم
|
| 138 |
+
draw_gradient(draw, CERT_WIDTH, CERT_HEIGHT, (255, 255, 250), (230, 240, 255))
|
| 139 |
+
|
| 140 |
+
# قاب حاشیهای چند لایه
|
| 141 |
+
for i, thickness in enumerate([6, 4, 2]):
|
| 142 |
+
color_val = 80 - i * 20
|
| 143 |
+
draw.rectangle(
|
| 144 |
+
[MARGIN - i*2, MARGIN - i*2, CERT_WIDTH - MARGIN + i*2, CERT_HEIGHT - MARGIN + i*2],
|
| 145 |
+
outline=(color_val, color_val, color_val)
|
| 146 |
+
)
|
| 147 |
+
|
| 148 |
+
# عنوان اصلی
|
| 149 |
+
title_text = "OpenAI – Certificate of Membership"
|
| 150 |
+
bbox = draw.textbbox((0, 0), title_text, font=font_title)
|
| 151 |
+
w = bbox[2] - bbox[0]
|
| 152 |
+
h = bbox[3] - bbox[1]
|
| 153 |
+
draw.text(((CERT_WIDTH - w) / 2, MARGIN + 10), title_text, fill=TITLE_COLOR, font=font_title)
|
| 154 |
+
|
| 155 |
+
# خط جداکننده زیبا
|
| 156 |
+
line_y = MARGIN + h + 30
|
| 157 |
+
draw.line([(MARGIN + 10, line_y), (CERT_WIDTH - MARGIN - 10, line_y)], fill=(100, 100, 120), width=3)
|
| 158 |
+
|
| 159 |
+
# نوشتن اطلاعات گواهی
|
| 160 |
+
info_x = MARGIN + 30
|
| 161 |
+
info_y = line_y + 20
|
| 162 |
+
line_spacing = 36
|
| 163 |
+
|
| 164 |
+
for key, val in cert_info.items():
|
| 165 |
+
text_line = f"{key}: {val}"
|
| 166 |
+
draw.text((info_x, info_y), text_line, font=font_text, fill=TEXT_COLOR)
|
| 167 |
+
info_y += line_spacing
|
| 168 |
+
|
| 169 |
+
# کد تایید اعتبار
|
| 170 |
+
verification_label = "Verification Code:"
|
| 171 |
+
verification_text = verification_code
|
| 172 |
+
info_y += 20
|
| 173 |
+
draw.text((info_x, info_y), verification_label, font=font_header, fill=TEXT_COLOR)
|
| 174 |
+
draw.text((info_x + 190, info_y), verification_text, font=font_header, fill=(0, 70, 120))
|
| 175 |
+
|
| 176 |
+
# متن امضای دیجیتال (شکسته به دو خط)
|
| 177 |
+
sig_half = len(digital_signature) // 2
|
| 178 |
+
sig_1 = digital_signature[:sig_half]
|
| 179 |
+
sig_2 = digital_signature[sig_half:]
|
| 180 |
+
draw.text((info_x, info_y + 40), sig_1, font=font_small, fill=(100, 100, 120))
|
| 181 |
+
draw.text((info_x, info_y + 60), sig_2, font=font_small, fill=(100, 100, 120))
|
| 182 |
+
|
| 183 |
+
# قرار دادن QR Code در پایین سمت راست
|
| 184 |
+
qr_pos = (CERT_WIDTH - qr_img.width - MARGIN - 20, CERT_HEIGHT - qr_img.height - MARGIN - 20)
|
| 185 |
+
|
| 186 |
+
# قرار دادن مهر رسمی بالای QR Code
|
| 187 |
+
seal_pos = (qr_pos[0], qr_pos[1] - official_seal.height - 15) # 15 پیکسل فاصله بالاتر
|
| 188 |
+
|
| 189 |
+
certificate.paste(official_seal, seal_pos, official_seal)
|
| 190 |
+
certificate.paste(qr_img, qr_pos, qr_img)
|
| 191 |
+
|
| 192 |
+
# ======== متنهای واترمارک عجیبتر و معتبرتر ========
|
| 193 |
+
watermarks = [
|
| 194 |
+
"AUTHORIZED", "CONFIDENTIAL", "OFFICIAL_USE_ONLY", "SECURE",
|
| 195 |
+
"AUTHENTICATED", "NON-TRANSFERABLE", "GOVERNMENT APPROVED", "VERIFIED BY BLOCKCHAIN",
|
| 196 |
+
"HIGHLY CONFIDENTIAL", "DIGITAL SIGNED", "SECURE DOCUMENT", "UNIQUE IDENTIFIER",
|
| 197 |
+
"ENCRYPTED SEAL",
|
| 198 |
+
cert_info["Certificate ID"], digital_signature[:16], verification_code,
|
| 199 |
+
"VALIDATED", "NO_COPY", "OPENAI"
|
| 200 |
+
]
|
| 201 |
+
|
| 202 |
+
# ======== اضافه کردن واترمارک نامرئی با فونت کوچک و زاویه تصادفی ========
|
| 203 |
+
for _ in range(80): # تعداد را کمی بیشتر کردم
|
| 204 |
+
wm_text = random.choice(watermarks)
|
| 205 |
+
txt_img = Image.new("RGBA", (220, 20), (0, 0, 0, 0))
|
| 206 |
+
txt_draw = ImageDraw.Draw(txt_img)
|
| 207 |
+
txt_draw.text((0, 0), wm_text, font=font_small, fill=WATERMARK_COLOR)
|
| 208 |
+
angle = random.uniform(-25, 25)
|
| 209 |
+
txt_img = txt_img.rotate(angle, expand=1)
|
| 210 |
+
|
| 211 |
+
# موقعیت تصادفی اما دور از لبهها
|
| 212 |
+
x = random.randint(MARGIN + 10, CERT_WIDTH - 230)
|
| 213 |
+
y = random.randint(MARGIN + 10, CERT_HEIGHT - 30)
|
| 214 |
+
certificate.paste(txt_img, (x, y), txt_img)
|
| 215 |
+
|
| 216 |
+
# ======== اضافه کردن نویز پیکسلی برای ضد جعل ========
|
| 217 |
+
pixels = certificate.load()
|
| 218 |
+
for _ in range(NOISE_INTENSITY):
|
| 219 |
+
px = random.randint(0, CERT_WIDTH - 1)
|
| 220 |
+
py = random.randint(0, CERT_HEIGHT - 1)
|
| 221 |
+
r, g, b, a = pixels[px, py]
|
| 222 |
+
noise = random.randint(-5, 5)
|
| 223 |
+
r = max(0, min(255, r + noise))
|
| 224 |
+
g = max(0, min(255, g + noise))
|
| 225 |
+
b = max(0, min(255, b + noise))
|
| 226 |
+
pixels[px, py] = (r, g, b, a)
|
| 227 |
+
|
| 228 |
+
# ======== ذخیره فایل نهایی ========
|
| 229 |
+
output_file = "openai_certificate_yasin_professional.png"
|
| 230 |
+
certificate.convert("RGB").save(output_file, quality=95)
|
| 231 |
+
print(f"✅ Professional certificate created: {output_file}")
|
cert/certificate_public_key.pem
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-----BEGIN PUBLIC KEY-----
|
| 2 |
+
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA1sv9ZBjtU6r22PLvS0m5
|
| 3 |
+
3VxKJyQPXTRcbKaWok+LTInCrQkr22YPbzU+kTRuUR/6W/DCSchKDPGoxlc/0Lsw
|
| 4 |
+
+ElNemSr0PTQqCGWUwdxBXcriDV54vld3Cqau1CSOh2tXSdDFJg2K31Ly4GFyudf
|
| 5 |
+
3UQt5Q/x8DhpTOZ42GuBWxX26NWF5wpBrNpkHESlTfAISyPMavQsn15AYfiPgsZF
|
| 6 |
+
zneyksFQ60cc4Oia4VwO4+8t1hoJ+8Vv0Z4qZsxx+wwktZkMB95APIw6OHdfkfDw
|
| 7 |
+
IZ5FjGxFZ3Xpnb0DY0MtG0WD879ZRst1yXvFaiatecBnDsS4RKef+mLi3KTZ1Z7P
|
| 8 |
+
V3mOcbM7MDQGiWAnpPY7sXryGmXJtv9psiwnEg9qjL2e2twmNwH5hAdKpgDHkUwz
|
| 9 |
+
aQ0WYdoOfuIZZhy+fXm9/Ns5s1H5vuCjpU5ez6yHvNwxh38ZnCHrR6tLlJd9tMeU
|
| 10 |
+
z9H18oVt3Un1NSCfRuP3HqvfOayG1JIIO+GRTgeQI7OYKSuTb2YBDAoHgyM1T3s8
|
| 11 |
+
ILgOq/TX/OptYBCaPwZSHipIOe9OlEy2LWu5MKzIfLJD6VGNjV5bxlxRQ1xX/166
|
| 12 |
+
nUxphNrC8ANuqXf2e5np75iDNqp1LWlFRbmOhaatAjeqW8Jx3mgmSEGEfSrGWtkt
|
| 13 |
+
MuifDdMENQ70+E+eb1Vqp+MCAwEAAQ==
|
| 14 |
+
-----END PUBLIC KEY-----
|
cert/encrypt_info_to_qrcode.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import qrcode
|
| 2 |
+
import base64
|
| 3 |
+
import json
|
| 4 |
+
from crypto.Cipher import AES
|
| 5 |
+
from crypto.Random import get_random_bytes
|
| 6 |
+
from crypto.Protocol.KDF import PBKDF2
|
| 7 |
+
from crypto.Util.Padding import pad
|
| 8 |
+
|
| 9 |
+
# ========== مرحله ۱: اطلاعات یاسین ==========
|
| 10 |
+
cert_info = {
|
| 11 |
+
"Name": "Yasin",
|
| 12 |
+
"Last Name": "Aryanfard",
|
| 13 |
+
"User ID": "YSNRFD",
|
| 14 |
+
"Membership Date": "April 1, 2023",
|
| 15 |
+
"Issued Date": "June 28, 2025",
|
| 16 |
+
"Certificate ID": "OPENAI-YSN-APR2023-CERT1001",
|
| 17 |
+
"Signed By": "ChatGPT-4o",
|
| 18 |
+
"Model ID": "GPT4O-REP-TRUST-2025",
|
| 19 |
+
"Issuer": "OpenAI, Inc."
|
| 20 |
+
}
|
| 21 |
+
data_json = json.dumps(cert_info).encode("utf-8")
|
| 22 |
+
|
| 23 |
+
# ========== مرحله ۲: رمزنگاری AES ==========
|
| 24 |
+
password = "ysn2025secure" # رمز عبور دلخواه شما
|
| 25 |
+
salt = get_random_bytes(16)
|
| 26 |
+
key = PBKDF2(password, salt, dkLen=32, count=100000) # کلید مشتقشده
|
| 27 |
+
|
| 28 |
+
cipher = AES.new(key, AES.MODE_CBC)
|
| 29 |
+
ciphertext = cipher.encrypt(pad(data_json, AES.block_size))
|
| 30 |
+
|
| 31 |
+
# ترکیب IV، salt و ciphertext برای رمزگشایی بعدی
|
| 32 |
+
payload = {
|
| 33 |
+
"salt": base64.b64encode(salt).decode(),
|
| 34 |
+
"iv": base64.b64encode(cipher.iv).decode(),
|
| 35 |
+
"data": base64.b64encode(ciphertext).decode()
|
| 36 |
+
}
|
| 37 |
+
payload_json = json.dumps(payload)
|
| 38 |
+
|
| 39 |
+
# ========== مرحله ۳: ساخت QR Code ==========
|
| 40 |
+
qr = qrcode.QRCode(error_correction=qrcode.constants.ERROR_CORRECT_Q)
|
| 41 |
+
qr.add_data(payload_json)
|
| 42 |
+
qr.make(fit=True)
|
| 43 |
+
img = qr.make_image(fill_color="#001133", back_color="white")
|
| 44 |
+
img.save("encrypted_yasin_qrcode.png")
|
| 45 |
+
|
| 46 |
+
print("✅ QR رمزنگاریشده ساخته شد و در فایل 'encrypted_yasin_qrcode.png' ذخیره شد.")
|
cert/image_details.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from PIL import Image, ExifTags
|
| 2 |
+
from collections import Counter
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
def extract_image_info(image_path):
|
| 6 |
+
if not os.path.exists(image_path):
|
| 7 |
+
print("فایل وجود ندارد!")
|
| 8 |
+
return
|
| 9 |
+
|
| 10 |
+
with Image.open(image_path) as img:
|
| 11 |
+
print("======== اطلاعات کلی ========")
|
| 12 |
+
print(f"فرمت: {img.format}")
|
| 13 |
+
print(f"ابعاد: {img.size} (عرض × ارتفاع)")
|
| 14 |
+
print(f"مود رنگی: {img.mode}")
|
| 15 |
+
print(f"اطلاعات DPI: {img.info.get('dpi', 'نامشخص')}")
|
| 16 |
+
print(f"دارای Alpha channel: {'A' in img.mode}")
|
| 17 |
+
print(f"اطلاعات دیگر: {img.info}")
|
| 18 |
+
|
| 19 |
+
print("\n======== رنگ غالب و میانگین ========")
|
| 20 |
+
img_rgb = img.convert('RGB')
|
| 21 |
+
pixels = list(img_rgb.getdata())
|
| 22 |
+
most_common = Counter(pixels).most_common(1)[0][0]
|
| 23 |
+
average_color = tuple(sum(x) // len(x) for x in zip(*pixels))
|
| 24 |
+
print(f"رنگ غالب: {most_common}")
|
| 25 |
+
print(f"میانگین رنگ: {average_color}")
|
| 26 |
+
|
| 27 |
+
print("\n======== هیستوگرام رنگی ========")
|
| 28 |
+
hist = img.histogram()
|
| 29 |
+
print(f"تعداد مقادیر هیستوگرام: {len(hist)}")
|
| 30 |
+
|
| 31 |
+
print("\n======== اطلاعات EXIF ========")
|
| 32 |
+
try:
|
| 33 |
+
exif_data = img._getexif()
|
| 34 |
+
if exif_data:
|
| 35 |
+
for tag, value in exif_data.items():
|
| 36 |
+
tag_name = ExifTags.TAGS.get(tag, tag)
|
| 37 |
+
print(f"{tag_name}: {value}")
|
| 38 |
+
else:
|
| 39 |
+
print("هیچ اطلاعات EXIF وجود ندارد.")
|
| 40 |
+
except Exception as e:
|
| 41 |
+
print(f"خطا در خواندن EXIF: {e}")
|
| 42 |
+
|
| 43 |
+
# ======= اجرا =======
|
| 44 |
+
path = "0002.png" # مسیر تصویر خود را اینجا وارد کنید
|
| 45 |
+
extract_image_info(path)
|
cert/image_details2.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import exiftool
|
| 2 |
+
import os
|
| 3 |
+
import json
|
| 4 |
+
|
| 5 |
+
def extract_all_metadata(image_path):
|
| 6 |
+
if not os.path.exists(image_path):
|
| 7 |
+
print("❌ فایل وجود ندارد.")
|
| 8 |
+
return
|
| 9 |
+
|
| 10 |
+
print(f"\n📂 فایل: {os.path.basename(image_path)}")
|
| 11 |
+
with exiftool.ExifTool() as et:
|
| 12 |
+
metadata = et.get_metadata(image_path)
|
| 13 |
+
|
| 14 |
+
if not metadata:
|
| 15 |
+
print("⛔️ هیچ متادیتایی پیدا نشد.")
|
| 16 |
+
return
|
| 17 |
+
|
| 18 |
+
print("\n📑 تمام metadata موجود:")
|
| 19 |
+
for key, value in metadata.items():
|
| 20 |
+
print(f"{key}: {value}")
|
| 21 |
+
|
| 22 |
+
# ذخیره در فایل JSON (اختیاری)
|
| 23 |
+
json_output = image_path + ".metadata.json"
|
| 24 |
+
with open(json_output, "w", encoding="utf-8") as f:
|
| 25 |
+
json.dump(metadata, f, indent=4, ensure_ascii=False)
|
| 26 |
+
print(f"\n✅ متادیتا در فایل ذخیره شد: {json_output}")
|
| 27 |
+
|
| 28 |
+
# مسیر عکس را وارد کن (فرمت PNG, JPG, WebP و ...)
|
| 29 |
+
image_file = "0002.png"
|
| 30 |
+
extract_all_metadata(image_file)
|
cert/info_to_qrcode.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import qrcode
|
| 2 |
+
from PIL import Image
|
| 3 |
+
|
| 4 |
+
# ===== اطلاعات گواهی یاسین =====
|
| 5 |
+
cert_info = {
|
| 6 |
+
"Name": "Yasin",
|
| 7 |
+
"Last Name": "Aryanfard",
|
| 8 |
+
"User ID": "YSNRFD",
|
| 9 |
+
"Membership Date": "April 1, 2023",
|
| 10 |
+
"Issued Date": "June 28, 2025",
|
| 11 |
+
"Certificate ID": "OPENAI-YSN-APR2023-CERT1001",
|
| 12 |
+
"Signed By": "ChatGPT-4o",
|
| 13 |
+
"Model ID": "GPT4O-REP-TRUST-2025",
|
| 14 |
+
"Issuer": "OpenAI, Inc."
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
# تبدیل به یک رشتهی قابل خواندن برای QR
|
| 18 |
+
qr_text = "\n".join(f"{k}: {v}" for k, v in cert_info.items())
|
| 19 |
+
|
| 20 |
+
# ساخت QR Code
|
| 21 |
+
qr = qrcode.QRCode(
|
| 22 |
+
version=1,
|
| 23 |
+
box_size=10,
|
| 24 |
+
border=4
|
| 25 |
+
)
|
| 26 |
+
qr.add_data(qr_text)
|
| 27 |
+
qr.make(fit=True)
|
| 28 |
+
|
| 29 |
+
# ساخت تصویر QR
|
| 30 |
+
img = qr.make_image(fill_color="black", back_color="white")
|
| 31 |
+
|
| 32 |
+
# ذخیره در فایل
|
| 33 |
+
img.save("yasin_certificate_qrcode.png")
|
| 34 |
+
print("✅ QR Code ساخته شد و در فایل 'yasin_certificate_qrcode.png' ذخیره شد.")
|
cert/private_key.pem
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-----BEGIN RSA PRIVATE KEY-----
|
| 2 |
+
MIIEpAIBAAKCAQEA+dE+xZ9jzrJJQJaG2ZOPcut/EI/QSgKIPRKHjk0LxAdnvPkh
|
| 3 |
+
yB7PnkRRPa1nU9PWy+rj1DtCm99jiRqsCyjg+CFI61947B45A39h93Rk7jiW+A9A
|
| 4 |
+
kAeyBYu7F0TusLp4RXIjkVFe4Bs+tBLmQ5pv/c5NLoi32kWlqgJkeBROWAQrPnX9
|
| 5 |
+
DY9WewQVHCa4Mwyfm0nMsQxsFMm2/9+KS/LklgEvPUmWU+tK6njXIUWvGu30PNPg
|
| 6 |
+
AK9Njz5EmNE9lufKkLeEFONsKEuGxKmKTSjJqiWyml7/DIfthSu5uMAXb5BYT6JS
|
| 7 |
+
qOxdTu5rw7Zpd1KfZaJDVnRemYwVknx+osOTYwIDAQABAoIBAAsYALVJS7xdFyWt
|
| 8 |
+
dEBAmPPd2LRak+xaym6z3kiHzAhLhTl+HW2ZTgJVlFSsg6nUVCCVcMKhqGaVoqzu
|
| 9 |
+
/fQ3lNilWcCiFROfOqGYzDfvTPV16+EI2bF2YLB1sRGVImhqD3c+B1hSXb05WIJ/
|
| 10 |
+
UwcY2kpSGVlXVvAe0amIFlVtdBaHxRHLcgIUqeMxI4Trhvi3cs3bPtbNY4Jfha3K
|
| 11 |
+
ATsYGC7VyJHyzFtmStGIv1KYRrrLlxoxp6uKNGejIsdMByQxOXrY6HzcojhbrFZZ
|
| 12 |
+
9zIXxDO/Z+PQwuMe9zk29Tps1v52KlsbaWkW745VE4lQAH/GIr3ZC1qFXf61RixZ
|
| 13 |
+
9YPjd9ECgYEA/msy02+DXQJN9Sgbcp2CiyeUmaGa/J2+e92Q/KckQqW4gfN5Wlgu
|
| 14 |
+
a0FnsCgFVWKVlTPkdb6uYdLtEpCrjOevEcD8ZC7tOVZf2Gm565fT1AMX15Th5ROv
|
| 15 |
+
Ka4ZxOc78NArJqdzinFBXYt90yT1ydvEgKGPepN/FwXNZ2iqXo0eHokCgYEA+165
|
| 16 |
+
uVS+ioFFUuDdN+YxfDiIt52SA0NKNSAMMtQaMn8URjhOSXQZ6zLiOONLyU8OK1T8
|
| 17 |
+
RQDVnm43tVnaHwdT5t49bRdExWU83izgLavk1xWZR1AkDQ1L2SP2cZp5nf2PSQ9x
|
| 18 |
+
Fu3WR0hapXyxZKnHTx4MZ2VkAhwIm8hnyl0pR4sCgYEA08I956ZlXEDSyj67ucZI
|
| 19 |
+
JbKoCMdtzN0u8sIUL3aew6pTzDXux7elyzgBKanl5o/LmQg8G5S+aEW7dTxczUb5
|
| 20 |
+
fHl4mZpFcPfnhqVZTjJs6YY5jgIpkxWzManrYOxmA6YAhIfTr2Nc2JOGAvw8Z+s3
|
| 21 |
+
vyi513h0y6DUukFvrIsgiqECgYAP/4Bcfjs+P2n1E2Cg7SKbIFH7NakUUhUH+oks
|
| 22 |
+
NvmP2yykJ3M8E4qOwIdLTZQGNOTW9yqzDZGK6sLa5OQP83xwhhZsuf1jfsT38u01
|
| 23 |
+
muoOkk5WDpCsz/rS0AogQs+YsYmMAdKVvf9UPBOg0qXLnU6VB3mMnxRVWglmOMP6
|
| 24 |
+
SiGVbwKBgQC3FP8iDUnj87Xzl18lyoV5zhBDaM7UbcdoK0mXtaaZkB4S3WnDZOjH
|
| 25 |
+
j6PK9sPnok7whbEkTBMCvkdCZMaNVNAo39t9idO1bpgfY+EIDxSXKt8Wd2Cm3Phe
|
| 26 |
+
cCkjC//X2Z+3sELonO694IbOxjKQyzmv0w2MTQEr+04xO0eh0os0mg==
|
| 27 |
+
-----END RSA PRIVATE KEY-----
|
cert/pub_key.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from cryptography.hazmat.primitives.asymmetric import rsa
|
| 2 |
+
from cryptography.hazmat.primitives import serialization
|
| 3 |
+
|
| 4 |
+
private_key = rsa.generate_private_key(public_exponent=65537, key_size=2048)
|
| 5 |
+
public_key = private_key.public_key()
|
| 6 |
+
|
| 7 |
+
with open("private_key.pem", "wb") as f:
|
| 8 |
+
f.write(private_key.private_bytes(
|
| 9 |
+
encoding=serialization.Encoding.PEM,
|
| 10 |
+
format=serialization.PrivateFormat.TraditionalOpenSSL,
|
| 11 |
+
encryption_algorithm=serialization.NoEncryption()
|
| 12 |
+
))
|
| 13 |
+
|
| 14 |
+
with open("public_key.pem", "wb") as f:
|
| 15 |
+
f.write(public_key.public_bytes(
|
| 16 |
+
encoding=serialization.Encoding.PEM,
|
| 17 |
+
format=serialization.PublicFormat.SubjectPublicKeyInfo
|
| 18 |
+
))
|
cert/public_key.pem
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-----BEGIN PUBLIC KEY-----
|
| 2 |
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+dE+xZ9jzrJJQJaG2ZOP
|
| 3 |
+
cut/EI/QSgKIPRKHjk0LxAdnvPkhyB7PnkRRPa1nU9PWy+rj1DtCm99jiRqsCyjg
|
| 4 |
+
+CFI61947B45A39h93Rk7jiW+A9AkAeyBYu7F0TusLp4RXIjkVFe4Bs+tBLmQ5pv
|
| 5 |
+
/c5NLoi32kWlqgJkeBROWAQrPnX9DY9WewQVHCa4Mwyfm0nMsQxsFMm2/9+KS/Lk
|
| 6 |
+
lgEvPUmWU+tK6njXIUWvGu30PNPgAK9Njz5EmNE9lufKkLeEFONsKEuGxKmKTSjJ
|
| 7 |
+
qiWyml7/DIfthSu5uMAXb5BYT6JSqOxdTu5rw7Zpd1KfZaJDVnRemYwVknx+osOT
|
| 8 |
+
YwIDAQAB
|
| 9 |
+
-----END PUBLIC KEY-----
|
cert/verifier.py
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from PIL import Image
|
| 2 |
+
import qrcode
|
| 3 |
+
import base64
|
| 4 |
+
import hashlib
|
| 5 |
+
from pyzbar.pyzbar import decode
|
| 6 |
+
from cryptography.hazmat.primitives.asymmetric import padding
|
| 7 |
+
from cryptography.hazmat.primitives import hashes, serialization
|
| 8 |
+
from cryptography.exceptions import InvalidSignature
|
| 9 |
+
|
| 10 |
+
# فایل تصویر گواهی
|
| 11 |
+
CERT_IMAGE_PATH = "openai_certificate_yasin_realistic.png"
|
| 12 |
+
|
| 13 |
+
# کلید عمومی PEM
|
| 14 |
+
PUBLIC_KEY_PATH = "public_key.pem"
|
| 15 |
+
|
| 16 |
+
# دادههای گواهی (باید دقیقا مثل دادههای اولیه باشه)
|
| 17 |
+
cert_info = {
|
| 18 |
+
"Name": "Yasin",
|
| 19 |
+
"Last Name": "Aryanfard",
|
| 20 |
+
"User ID": "YSNRFD",
|
| 21 |
+
"Membership Date": "April 1, 2023",
|
| 22 |
+
"Issued Date": "June 28, 2025",
|
| 23 |
+
"Certificate ID": "OPENAI-YSN-APR2023-CERT1001",
|
| 24 |
+
"Signed By": "ChatGPT-4o",
|
| 25 |
+
"Model ID": "GPT4O-REP-TRUST-2025",
|
| 26 |
+
"Issuer": "OpenAI, Inc."
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
def extract_qr_signature(image_path):
|
| 30 |
+
img = Image.open(image_path)
|
| 31 |
+
decoded_objs = decode(img)
|
| 32 |
+
for obj in decoded_objs:
|
| 33 |
+
data = obj.data.decode('utf-8')
|
| 34 |
+
if data.startswith("-----"): # اگر کلید عمومی یا امضای بزرگ باشه
|
| 35 |
+
continue
|
| 36 |
+
return data # اولین داده QR کد که امضا هست
|
| 37 |
+
return None
|
| 38 |
+
|
| 39 |
+
def extract_stego_message(img):
|
| 40 |
+
pixels = img.load()
|
| 41 |
+
width, height = img.size
|
| 42 |
+
bits = []
|
| 43 |
+
for y in range(height):
|
| 44 |
+
for x in range(width):
|
| 45 |
+
r, g, b, *rest = pixels[x, y]
|
| 46 |
+
bits.append(str(r & 1))
|
| 47 |
+
# تبدیل بیتها به کاراکترها
|
| 48 |
+
chars = []
|
| 49 |
+
for i in range(0, len(bits), 8):
|
| 50 |
+
byte = bits[i:i+8]
|
| 51 |
+
if len(byte) < 8:
|
| 52 |
+
break
|
| 53 |
+
byte_str = ''.join(byte)
|
| 54 |
+
char = chr(int(byte_str, 2))
|
| 55 |
+
if char == '\x00': # پایان پیام فرضی
|
| 56 |
+
break
|
| 57 |
+
chars.append(char)
|
| 58 |
+
return ''.join(chars)
|
| 59 |
+
|
| 60 |
+
def verify_signature(public_key, signature, data):
|
| 61 |
+
try:
|
| 62 |
+
public_key.verify(
|
| 63 |
+
signature,
|
| 64 |
+
data,
|
| 65 |
+
padding.PSS(
|
| 66 |
+
mgf=padding.MGF1(hashes.SHA256()),
|
| 67 |
+
salt_length=padding.PSS.MAX_LENGTH
|
| 68 |
+
),
|
| 69 |
+
hashes.SHA256()
|
| 70 |
+
)
|
| 71 |
+
return True
|
| 72 |
+
except InvalidSignature:
|
| 73 |
+
return False
|
| 74 |
+
|
| 75 |
+
def main():
|
| 76 |
+
# بارگذاری تصویر
|
| 77 |
+
img = Image.open(CERT_IMAGE_PATH).convert("RGBA")
|
| 78 |
+
|
| 79 |
+
# استخراج امضا از QR
|
| 80 |
+
digital_signature_base64 = extract_qr_signature(CERT_IMAGE_PATH)
|
| 81 |
+
if not digital_signature_base64:
|
| 82 |
+
print("❌ امضا دیجیتال در QR کد یافت نشد!")
|
| 83 |
+
return
|
| 84 |
+
|
| 85 |
+
print("📥 امضا دیجیتال استخراج شده از QR کد.")
|
| 86 |
+
|
| 87 |
+
# استخراج پیام استگانوگرافی (CertificateID و VerificationCode)
|
| 88 |
+
stego_msg = extract_stego_message(img)
|
| 89 |
+
print(f"📥 پیام مخفی استگانوگرافی: {stego_msg}")
|
| 90 |
+
|
| 91 |
+
# بازسازی رشته داده برای امضا (باید دقیقاً مثل زمان ساخت گواهی)
|
| 92 |
+
data_string = "\n".join(f"{k}: {v}" for k, v in cert_info.items()).encode('utf-8')
|
| 93 |
+
|
| 94 |
+
# بارگذاری کلید عمومی
|
| 95 |
+
with open(PUBLIC_KEY_PATH, "rb") as f:
|
| 96 |
+
public_key = serialization.load_pem_public_key(f.read())
|
| 97 |
+
|
| 98 |
+
# تبدیل امضا به بایت
|
| 99 |
+
signature_bytes = base64.b64decode(digital_signature_base64)
|
| 100 |
+
|
| 101 |
+
# بررسی امضا
|
| 102 |
+
if verify_signature(public_key, signature_bytes, data_string):
|
| 103 |
+
print("✅ امضا دیجیتال معتبر است.")
|
| 104 |
+
else:
|
| 105 |
+
print("❌ امضا دیجیتال نامعتبر است یا دادهها تغییر کردهاند!")
|
| 106 |
+
|
| 107 |
+
# بررسی کد تأیید در پیام استگانوگرافی
|
| 108 |
+
expected_verification_code = f"VER-{hashlib.sha256(data_string).hexdigest()[:8].upper()}-{cert_info['Certificate ID'][-4:]}"
|
| 109 |
+
if expected_verification_code in stego_msg:
|
| 110 |
+
print("✅ کد تأیید در پیام مخفی استگانوگرافی معتبر است.")
|
| 111 |
+
else:
|
| 112 |
+
print("❌ کد تأیید در پیام مخفی یافت نشد یا اشتباه است!")
|
| 113 |
+
|
| 114 |
+
if __name__ == "__main__":
|
| 115 |
+
main()
|