예제 #1
0
        public MainPage()
        {
            this.InitializeComponent();

            string key = "jk4c6nbf6huccmwp";
            string label = "UWP TOTP";

            otp = new OTP(key);

            xImage.Source = otp.QRCode(key, label, 200, 200);

            timer = new DispatcherTimer();
            timer.Tick += Timer_Tick;
            timer.Interval = new TimeSpan(0, 0, 30);
            // by design (at least ms and google authenticator) change every 30 seconds(@ 0 and 30)
            while (DateTime.Now.Second != 0 && DateTime.Now.Second != 30) ;
            timer.Start();
        }
예제 #2
0
파일: Program.cs 프로젝트: cyberh0me/OTP
        public static void Main()
        {
            string key = "jk4c6nbf6huccmwp";
            string label = ".NETmf TOTP";

            Bitmap screen = new Bitmap(320, 240);   // emulator display size
            Font font = Resources.GetFont(Resources.FontResources.NinaB);

            otp = new OTP(key);

            Bitmap qrcode = otp.QRCode(key, label);
            screen.DrawImage(10, 10, qrcode, 0, 0, qrcode.Width, qrcode.Height);

            // by design (at least ms and google authenticator) change every 30 seconds(@ 0 and 30)
            while (DateTime.Now.Second != 0 && DateTime.Now.Second != 30) ;

            while (true)
            {
                screen.DrawRectangle(Color.Black, 1, 220, 10, 100, 32, 0, 0, Color.Black, 0, 0, Color.Black, 50, 30, 0xff);
                screen.DrawText(otp.TOTP, font, Color.White, 220, 10);
                screen.Flush();
                Thread.Sleep(30000);
            }
        }