import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class LicenseManager { private static final String SECRET_KEY = "YourSecretKey"; // ½ÃÅ©¸´ Ű public static String generateLicenseKey(String computerName) { try { MessageDigest sha1 = MessageDigest.getInstance("SHA-1"); byte[] inputBytes = (computerName + SECRET_KEY).getBytes(StandardCharsets.UTF_8); byte[] hashBytes = sha1.digest(inputBytes); StringBuilder hexString = new StringBuilder(); for (byte hashByte : hashBytes) { String hex = Integer.toHexString(0xff & hashByte); if (hex.length() == 1) { hexString.append('0'); } hexString.append(hex); } return hexString.toString(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); return null; } } public static boolean validateLicenseKey(String computerName, String licenseKey) { return licenseKey.equals(generateLicenseKey(computerName)); } public static void main(String[] args) { String computerName = System.getenv("COMPUTERNAME"); // ÄÄÇ»ÅÍ À̸§ °¡Á®¿À±â String licenseKey = generateLicenseKey(computerName); System.out.println("Generated license key for " + computerName + ": " + licenseKey); // Validate the license key boolean isValid = validateLicenseKey(computerName, licenseKey); System.out.println("License key is valid: " + isValid); } }