//
//  Hacks.m
//  App
//
//  Created by James Magahern on 5/5/25.
//

#import "Hacks.h"
#import <objc/runtime.h>

Class DecodedClass(const char *encodedClassName) {
    NSData *data = [NSData dataWithBytesNoCopy:(void *)encodedClassName length:strlen(encodedClassName) freeWhenDone:NO];
    data = [[NSData alloc] initWithBase64EncodedData:data options:0];
    
    NSString *str = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
    return NSClassFromString(str);
}

SEL DecodedSelector(const char *encodedSelectorName) {
    NSData *data = [NSData dataWithBytesNoCopy:(void *)encodedSelectorName length:strlen(encodedSelectorName) freeWhenDone:NO];
    data = [[NSData alloc] initWithBase64EncodedData:data options:0];
    
    NSString *str = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
    return NSSelectorFromString(str);
}

void SwizzleClassMethod(Class targetClass, SEL originalSelector, IMP replacementIMP)
{
    Method originalMethod = class_getClassMethod(targetClass, originalSelector);
    method_setImplementation(originalMethod, replacementIMP);
}
