Wednesday 15 June 2016

Creating HMAC in postman using CryptoJS

Place this script at pre-request-script and environment.secret is stored in environment variables or pass hardcoded here.
It will convert HMAC(.SHA256, /URI + /Body) and place into a global variable name as signature. which can pass on header like: x-pch-digest:{{signature}}

var index = request.url.indexOf('/');
var uri_path = request.url.substring(index);
var payload = uri_path + request.data;
console.log("Using payload as " + payload)
var hash = CryptoJS.HmacSHA256(payload, environment.secret);
var hashInBase64 = CryptoJS.enc.Hex.stringify(hash);
postman.setGlobalVariable("signature", hashInBase64);


Code signing using terminal

codesign --verify --force --sign "$CODE_SIGN_IDENTITY" "$CODESIGNING_FOLDER_PATH"
Walk through : http://stackoverflow.com/questions/20344255/secitemadd-and-secitemcopymatching-returns-error-code-34018-errsecmissingentit/22305193#22305193

Find UIViewController of the UIView in objective-c [Backtracking]

@interface UIView(UIViewControllerFinder)

- (UIViewController*)viewController;

@end


@implementation UIView(UIViewControllerFinder)

- (UIViewController*)viewController {
    for (UIView* next = [self superview]; next; next = next.superview) {
        UIResponder* nextResponder = [next nextResponder];
        if ([nextResponder isKindOfClass:[UIViewController class]]) {
            return (UIViewController*)nextResponder;
        }
    }
    return nil;
}

@end

Try this code for find view-controller of view self.btnSubmit (UIButton) or any object inherits from UIView
UIViewController *vc = [self.btnSubmit viewController];