public static async Task <ApiResponse> EncryptWallet(string password) { ApiResponse response = new ApiResponse(); try { var regex = new Regex(@"((?=.*[0-9])(?=.*[a-zA-Z])(?=.*[!@#$%^&*\.])[a-zA-Z0-9!@#$%^&*\._-]+)|((?=.*[0-9])(?=.*[a-zA-Z])[a-zA-Z0-9]+)|((?=.*[0-9])(?=.*[!@#$%^&*\.])[0-9!@#$%^&*\._-]+)|((?=.*[!@#$%^&*\.])(?=.*[a-zA-Z])[a-zA-Z!@#$%^&*\._-]+).{7,30}"); var mathches = regex.Matches(password).Cast <Match>(); var gs = mathches.SelectMany(x => x.Groups.Cast <Group>()); if (!gs.Any(x => x.Value.Equals(password) && x.Value.Length >= 8 && x.Value.Length <= 30)) { throw new ApiCustomException(7000001, "invalid password"); } WalletManagement management = new WalletManagement(); await management.EncryptWallet(password); } catch (ApiCustomException ex) { Logger.Singleton.Error(ex.Message); response.Error = new ApiError(ex.ErrorCode, ex.Message); } catch (Exception ex) { Logger.Singleton.Error(ex.Message); response.Error = new ApiError(ex.HResult, ex.Message); } return(response); }
public async Task EncryptWallet() { WalletManagement management = new WalletManagement(); await management.EncryptWallet("P@ssw0rd"); }