-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathQreditBIP39Service.cs
26 lines (24 loc) · 1.03 KB
/
QreditBIP39Service.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using dotnetstandard_bip39;
namespace Qredit
{
public static class QreditBIP39Service
{
[FunctionName("GenerateRandomMnemonic")]
public static IActionResult GenerateRandomMnemonic([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req)
{
return new OkObjectResult(new BIP39().GenerateMnemonic(128, BIP39Wordlist.English).Trim().Replace("\r", ""));
}
[FunctionName("GetKeyFromMnemonic")]
public static async Task<IActionResult> GetKeyFromMnemonic([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req)
{
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
return new OkObjectResult( new BIP39().MnemonicToSeedHex(requestBody, string.Empty));
}
}
}