示例#1
0
        private string GetQRCodeUrl()
        {
            // https://code.google.com/p/google-authenticator/wiki/KeyUriFormat
            var base32Secret = Base32.Encode(secret);

            return(String.Format("https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/{0}%3Fsecret%3D{1}", Identity, base32Secret));
        }
示例#2
0
        public MainWindow()
        {
            InitializeComponent();

            DataContext = this;


            var timer = new DispatcherTimer();

            timer.Interval  = TimeSpan.FromMilliseconds(500);
            timer.Tick     += (s, e) => SecondsToGo = 30 - Convert.ToInt32(DateTimeOffset.UtcNow.ToUnixTimeSeconds() % 30);
            timer.IsEnabled = true;

            secret   = new byte[] { 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x21, 0xDE, 0xAD, 0xBE, 0xEF };
            Secret   = Base32.Encode(secret);
            Identity = "*****@*****.**";

            QRCodeUrl = GetQRCodeUrl();
        }