Skip to content

Instantly share code, notes, and snippets.

@huoshan12345
huoshan12345 / encrypt.cs
Last active April 15, 2025 13:45
Instagram enc_password generator in C#
// Packages need to be installed:
// Sodium.Core
// System.Security.Cryptography.Algorithms
// The values of publicKey,keyId,version are from shared_data.
// You need to call https://www.instagram.com/data/shared_data/ to get shared_data first
public static string GenerateEncPassword(string password, string publicKey, string keyId, string version)
{
var time = DateTime.UtcNow.ToTimestamp(); // Unix timestamp
var keyBytes = publicKey.HexToBytes(); // Convert a hex string to a byte array
@huoshan12345
huoshan12345 / InterfaceBaseInvocationExtension.cs
Last active June 10, 2022 03:05
Interface Base Invocation
public static class InterfaceBaseInvocationExtension
{
private readonly record struct InterfaceMethodInfo(Type InstanceType, Type InterfaceType, MethodInfo Method);
private static readonly ConcurrentDictionary<InterfaceMethodInfo, Delegate> _delegates = new();
private readonly struct Unit { }
public static void Base<TInterface>(this TInterface instance, Expression<Action<TInterface>> selector)
{