1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Pin generator

Discussion in 'Development' started by RiseMCPE, Jul 14, 2021.

  1. RiseMCPE

    RiseMCPE Spider

    Messages:
    14
    I have pin plugin for vip sales. But these pins are extremely long and difficult. How can I generate 10 letter codes consisting of numbers and letters only?

    PHP:
    <?php

    namespace androcyber\utils;

    class 
    AutomaticPinSystem{

        private const 
    LENGTH "\x31\x30";

        public const 
    DAYS = [
            
    "Monday" => "Pazartesi",
            
    "Tuesday" => "Salı",
            
    "Wednesday" => "Çarşamba",
            
    "Thursday" => "Perşembe",
            
    "Friday" => "Cuma",
            
    "Saturday" => "Cumartesi",
            
    "Sunday" => "Pazar"
        
    ];

        public static function 
    generatePin() : ?string{
            try{
                return 
    STATIC_PIN_PREFIX "-" strtoupper(bin2hex(random_bytes((int) self::LENGTH)));
            }catch(\
    Exception $exception){
                return static::
    generatePin();
            }
        }

        public static function 
    diffTime(int $finish) : string{
            
    $now = new \DateTime();
            
    $finishDateTime = new \DateTime();
            
    $finishDateTime->setTimestamp($finish);
            
    $finishDate = new \DateTime((string)$finishDateTime->format('Y-m-d H:i:s'));
            
    $remainingTime $now->diff($finishDate);
            return 
    $remainingTime->format('%m Ay, %d Gün, %H Saat, %i Dakika, %s Saniye');
        }
    }
    ?>
    i think private const LENGTH = "\x31\x30"; and return STATIC_PIN_PREFIX . "-" . strtoupper(bin2hex(random_bytes((int) self::LENGTH)));

    but i dont know how to change this.
     
  2. Primus

    Primus Zombie Pigman

    Messages:
    749
  3. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    PHP:
    $pass substr(md5(uniqid(mt_rand(), true)) , 010);
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.