close

using OtpNet; 
using Microsoft.AspNetCore.WebUtilities;

Tokn.secretKey = KeyGeneration.GenerateRandomKey();
String secretKey = Base32Encoding.ToString(Tokn.secretKey);
UriBuilder uriBuilder = new UriBuilder();
uriBuilder.Scheme = "otpauth";
uriBuilder.Host = "totp";
uriBuilder.Path = appname;
var query = new Dictionary<string, string>();
query.Add("issuer", issuer);
query.Add("secret", secretKey);
//寫入DB
string strsql = $@"update table  set KEY = '{secretKey}' WHERE user_id = '{issuer}'";
_oracleService.ExecuteCommitSQL(strsql);
var uri = uriBuilder.ToString();
uri = QueryHelpers.AddQueryString(uri, query);

--------------------------------------------------------

public class Tokn
    {
        public static byte[] secretKey = null;
        public static void createSecretKey()
        {
           secretKey = KeyGeneration.GenerateRandomKey();
        }
    }

arrow
arrow
    全站熱搜

    程式小試身手 發表在 痞客邦 留言(0) 人氣()