Skip to content

Instantly share code, notes, and snippets.

View xbotter's full-sized avatar
:octocat:

xbotter xbotter

:octocat:
  • China , ShangHai
  • 13:19 (UTC +08:00)
View GitHub Profile
@xbotter
xbotter / Aes.cs
Created September 3, 2021 11:12
天瑞融通 API接口使用到的C#加密方法
private static string AesEncrypt(string cleartext, string password)
{
var aes = Aes.Create();
var sha1 = SHA1.Create();
byte[] hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(password));
var rd = sha1.ComputeHash(hash);
var keyArray = rd.Take(16).ToArray();
aes.Key = keyArray;
aes.Mode = CipherMode.ECB;
var byteBuff = Encoding.UTF8.GetBytes(cleartext);
@xbotter
xbotter / AzureAppServiceMysqlConnectionParser.cs
Created December 18, 2022 02:31
Parse Azure App Service MYSQLCONNSTR to EF connectionstring
public class AzureAppServiceMysqlConnectionParser
{
const string Database = nameof(Database);
const string Server = "Data Source";
const string UId = "User Id";
const string Pwd = "Password";
// example: Database={database};Data Source={host}:{port};User Id={username};Password={password}
public static string Parse(string mysqlconnstr) {
@xbotter
xbotter / MockHttpClient.cs
Created May 19, 2023 06:10
如何Mock一个HttpClient
var httpClientMock = new Mock<HttpClient>();
// Set up the SendAsync method to return a desired response
httpClientMock
.Setup(x => x.SendAsync(It.IsAny<HttpRequestMessage>(), CancellationToken.None))
.ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK));
// Set up the SendAsync method to match a specific URL and return a desired response
httpClientMock
.Setup(x => x.SendAsync(It.Is<HttpRequestMessage>(req => req.RequestUri.AbsoluteUri == "https://example.com/api/data"), CancellationToken.None))
.ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent("Mocked response") });

.NET 软件开发工程师

  • 岗位职责:
    1、负责编写公司应用层逻辑、做一些轻量级的数据分析。
    2、负责所属模块的代码开发、调试与维护工作;
    3、参与公司产品的架构优化,性能优化并辅助其他模块进行技术实现;
    4、协助并完成其他各类技术开发任务。

  • 岗位要求:
    1、计算机或者相关专业,统招全日制本科及以上学历。

@xbotter
xbotter / dotnet-ef-migration-script.ps1
Created November 22, 2023 08:50
Generate dotnet ef migration scripts for all migrations that don't have a script yet
# build the latest code
dotnet build
# get all migration ids and store them in an array
$migrations = dotnet ef migrations list --no-build --no-connect --json | ConvertFrom-Json
# iterate through the array
for ($i = 0; $i -lt $migrations.Length; $i++) {
# get the current migration id