ysn-rfd's picture
cert folder have many of fake certificate image and their code, realistic, fake, no_copy, no_copy, no_copy, warning, no_copy
5163f6c verified
raw
history blame
10.3 kB
from PIL import Image, ImageDraw, ImageFont, ImageFilter, ImageEnhance
import qrcode
import hashlib
import random
import math
import os
import base64
# برای امضای دیجیتال واقعی:
from cryptography.hazmat.primitives.asymmetric import rsa, padding
from cryptography.hazmat.primitives import hashes, serialization
# ======== تنظیمات قابل تغییر ========
CERT_WIDTH, CERT_HEIGHT = 900, 650
MARGIN = 30
BACKGROUND_COLOR = (255, 255, 250)
BORDER_COLOR = (60, 60, 60)
TITLE_COLOR = (20, 20, 20)
TEXT_COLOR = (40, 40, 40)
WATERMARK_COLOR = (60, 60, 60, 25)
NOISE_INTENSITY = 100000
# ======== اطلاعات گواهی ========
cert_info = {
"Name": "Yasin",
"Last Name": "Aryanfard",
"User ID": "YSNRFD",
"Membership Date": "April 1, 2023",
"Issued Date": "June 28, 2025",
"Certificate ID": "OPENAI-YSN-APR2023-CERT11011010",
"Signed By": "ChatGPT-4o",
"Model ID": "GPT4O-REP-TRUST-2025",
"Issuer": "OpenAI, Inc."
}
# ======== کلیدهای RSA برای امضای دیجیتال ========
def generate_rsa_keys():
private_key = rsa.generate_private_key(public_exponent=65537, key_size=2048)
public_key = private_key.public_key()
return private_key, public_key
private_key, public_key = generate_rsa_keys()
# ======== تابع بارگذاری فونت پویا با fallback ========
def load_font(name, size):
paths = [
name,
os.path.join("/usr/share/fonts/truetype/dejavu/", name),
os.path.join("/Library/Fonts/", name),
os.path.join("C:/Windows/Fonts/", name)
]
for path in paths:
try:
return ImageFont.truetype(path, size)
except:
continue
return ImageFont.load_default()
font_title = load_font("timesbd.ttf", 36) # فونت رسمی‌تر
font_header = load_font("timesbd.ttf", 20)
font_text = load_font("times.ttf", 18)
font_small = load_font("times.ttf", 14)
# ======== تولید رشته داده برای امضا دیجیتال ========
data_string = "\n".join(f"{k}: {v}" for k, v in cert_info.items()).encode('utf-8')
# امضای دیجیتال واقعی با کلید خصوصی
digital_signature_bytes = private_key.sign(
data_string,
padding.PSS(
mgf=padding.MGF1(hashes.SHA256()),
salt_length=padding.PSS.MAX_LENGTH
),
hashes.SHA256()
)
digital_signature = base64.b64encode(digital_signature_bytes).decode('utf-8')
verification_code = f"VER-{hashlib.sha256(data_string).hexdigest()[:8].upper()}-{cert_info['Certificate ID'][-4:]}"
# ======== ایجاد QR code لینک اعتبارسنجی آنلاین ========
validation_url = f"cert_id={cert_info['Certificate ID']}&code={verification_code}"
# ======== ایجاد QR code فقط با امضای دیجیتال ========
def create_qr_code(data, size=180):
qr = qrcode.QRCode(box_size=8, border=3)
qr.add_data(data)
qr.make(fit=True)
qr_img = qr.make_image(fill_color="#003366", back_color="white").convert("RGBA")
qr_img = qr_img.resize((size, size), Image.Resampling.LANCZOS)
return qr_img
qr_img = create_qr_code(digital_signature, size=180)
# ======== طراحی پس‌زمینه با گرادیانت ملایم ========
def draw_gradient(draw, width, height, start_color, end_color):
for i in range(height):
r = int(start_color[0] + (float(i) / height) * (end_color[0] - start_color[0]))
g = int(start_color[1] + (float(i) / height) * (end_color[1] - start_color[1]))
b = int(start_color[2] + (float(i) / height) * (end_color[2] - start_color[2]))
draw.line([(0, i), (width, i)], fill=(r, g, b))
# ======== رسم مهر رسمی پیشرفته ========
def create_official_seal(diameter=160):
seal = Image.new("RGBA", (diameter, diameter), (0, 0, 0, 0))
draw = ImageDraw.Draw(seal)
center = diameter // 2
# حلقه بیرونی با گرادیانت شعاعی قوی‌تر
for i in range(10):
alpha = int(255 * (1 - i/10))
radius = center - i*5
color = (0, 51, 102, alpha)
draw.ellipse(
[(center - radius, center - radius), (center + radius, center + radius)],
outline=color,
width=3 if i % 2 == 0 else 2
)
# خطوط شعاعی تزئینی بیشتر و پرجزئیات‌تر
num_rays = 36
outer_r = center - 15
inner_r = center - 50
for i in range(num_rays):
angle = 360 / num_rays * i
x1 = center + int(inner_r * math.cos(math.radians(angle)))
y1 = center + int(inner_r * math.sin(math.radians(angle)))
x2 = center + int(outer_r * math.cos(math.radians(angle)))
y2 = center + int(outer_r * math.sin(math.radians(angle)))
draw.line([(x1, y1), (x2, y2)], fill=(0, 51, 102, 200), width=2)
# قرار دادن لوگوی openai_seal.png وسط مهر اگر موجود باشد
try:
logo = Image.open("openai_seal.png").convert("RGBA")
max_logo_size = diameter - 100
logo.thumbnail((max_logo_size, max_logo_size), Image.Resampling.LANCZOS)
logo_pos = (center - logo.width // 2, center - logo.height // 2)
seal.paste(logo, logo_pos, logo)
except FileNotFoundError:
print("⚠️ فایل openai_seal.png پیدا نشد! مهر بدون لوگو ساخته شد.")
# متن مهر دایره‌ای قوی‌تر و خواناتر
seal_text = "OFFICIAL OPENAI SEAL"
font_circle = load_font("timesbd.ttf", 18)
radius_text = center - 20
for i, char in enumerate(seal_text):
angle_deg = (360 / len(seal_text)) * i - 90
angle_rad = math.radians(angle_deg)
x = center + int(radius_text * math.cos(angle_rad))
y = center + int(radius_text * math.sin(angle_rad))
draw.text((x-8, y-8), char, font=font_circle, fill=(0, 51, 102, 255))
# سایه قوی‌تر و واضح‌تر
seal = seal.filter(ImageFilter.GaussianBlur(radius=0.5))
return seal
official_seal = create_official_seal()
# ======== ایجاد تصویر گواهی ========
certificate = Image.new("RGBA", (CERT_WIDTH, CERT_HEIGHT), BACKGROUND_COLOR)
draw = ImageDraw.Draw(certificate)
draw_gradient(draw, CERT_WIDTH, CERT_HEIGHT, (255, 255, 250), (220, 230, 255))
for i, thickness in enumerate([6, 4, 2]):
color_val = 80 - i * 20
draw.rectangle(
[MARGIN - i*2, MARGIN - i*2, CERT_WIDTH - MARGIN + i*2, CERT_HEIGHT - MARGIN + i*2],
outline=(color_val, color_val, color_val)
)
# عنوان اصلی
title_text = "OpenAI – Certificate of Membership"
bbox = draw.textbbox((0, 0), title_text, font=font_title)
w = bbox[2] - bbox[0]
h = bbox[3] - bbox[1]
draw.text(((CERT_WIDTH - w) / 2, MARGIN + 10), title_text, fill=TITLE_COLOR, font=font_title)
line_y = MARGIN + h + 30
draw.line([(MARGIN + 10, line_y), (CERT_WIDTH - MARGIN - 10, line_y)], fill=(100, 100, 120), width=3)
info_x = MARGIN + 30
info_y = line_y + 20
line_spacing = 36
for key, val in cert_info.items():
text_line = f"{key}: {val}"
draw.text((info_x, info_y), text_line, font=font_text, fill=TEXT_COLOR)
info_y += line_spacing
verification_label = "Verification Code:"
verification_text = verification_code
info_y += 20
draw.text((info_x, info_y), verification_label, font=font_header, fill=TEXT_COLOR)
draw.text((info_x + 190, info_y), verification_text, font=font_header, fill=(0, 70, 120))
sig_lines = [digital_signature[i:i+60] for i in range(0, len(digital_signature), 60)]
sig_y = info_y + 40
for line in sig_lines:
draw.text((info_x, sig_y), line, font=font_small, fill=(100, 100, 120))
sig_y += 20
qr_pos = (CERT_WIDTH - qr_img.width - MARGIN - 20, CERT_HEIGHT - qr_img.height - MARGIN - 20)
seal_pos = (qr_pos[0], qr_pos[1] - official_seal.height - 15)
certificate.paste(official_seal, seal_pos, official_seal)
certificate.paste(qr_img, qr_pos, qr_img)
watermarks = [
"AUTHORIZED", "CONFIDENTIAL", "OFFICIAL_USE_ONLY", "SECURE",
"AUTHENTICATED", "NON-TRANSFERABLE", "GOVERNMENT APPROVED", "VERIFIED BY BLOCKCHAIN",
"HIGHLY CONFIDENTIAL", "DIGITAL SIGNED", "SECURE DOCUMENT", "UNIQUE IDENTIFIER",
"ENCRYPTED SEAL",
cert_info["Certificate ID"], verification_code,
"VALIDATED", "NO_COPY", "OPENAI"
]
for _ in range(128):
wm_text = random.choice(watermarks)
txt_img = Image.new("RGBA", (220, 20), (0, 0, 0, 0))
txt_draw = ImageDraw.Draw(txt_img)
txt_draw.text((0, 0), wm_text, font=font_small, fill=WATERMARK_COLOR)
angle = random.uniform(-25, 25)
txt_img = txt_img.rotate(angle, expand=1)
x = random.randint(MARGIN + 10, CERT_WIDTH - 230)
y = random.randint(MARGIN + 10, CERT_HEIGHT - 30)
certificate.paste(txt_img, (x, y), txt_img)
pixels = certificate.load()
for _ in range(NOISE_INTENSITY):
px = random.randint(0, CERT_WIDTH - 1)
py = random.randint(0, CERT_HEIGHT - 1)
r, g, b, a = pixels[px, py]
noise = random.randint(-5, 5)
r = max(0, min(255, r + noise))
g = max(0, min(255, g + noise))
b = max(0, min(255, b + noise))
pixels[px, py] = (r, g, b, a)
# ======== استگانوگرافی ساده برای درج کد امنیتی پنهان ========
def encode_message_in_pixels(img, message):
binary_message = ''.join(format(ord(i), '08b') for i in message)
pixels = img.load()
width, height = img.size
idx = 0
for y in range(height):
for x in range(width):
if idx >= len(binary_message):
return
r, g, b, a = pixels[x, y]
r = (r & ~1) | int(binary_message[idx])
pixels[x, y] = (r, g, b, a)
idx += 1
hidden_message = f"CertificateID:{cert_info['Certificate ID']};VerificationCode:{verification_code}"
encode_message_in_pixels(certificate, hidden_message)
output_file = f"OpenAI_Certificate_{cert_info['Certificate ID']}.png"
certificate.convert("RGB").save(output_file, quality=100)
print(f"✅ Realistic and highly secure certificate created: {output_file}")