Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
774 views
in Technique[技术] by (71.8m points)

encryption - Objective-C, how to obfuscate or encrypt NSString?

I have an NSString (which is a path to a file) in my code that I would like to somehow obfuscate or encrypt,

but still be able to call up the file path easily when needed. I searched for an answer to this, but everything I've seen either deals specifically with iOS or seems overly complicated.

I would simply like to use it with something such as this:

- (void)method {

NSString *obfuscate = @"/path/to/something/secret"; // encrypt or obfuscate

[self manageFiles:obfuscate]

- (void)manageFiles(NSString *)obfuscate {

    NSFileManager *files = [[NSFileManager alloc] init];

    if ([files fileExistsAtPath:obfuscate])

    ... .

— any help is appreciated, thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

(This is an old question, but I'm replying anyway)

There's no such way to in Obj-C. Obj-C is dynamic enough that any of these methods can be trapped and intercepted. Do not ship anything in a application that absolutely needs to be secret. If your application is run on a jailbroken phone, or if it is made available on piracy sites, than it has already been exposed and it's memory contents dumped. All these above methods copy the decoded data to main memory where it is exposed.

See: https://www.youtube.com/watch?v=Ii-02vhsdVk

None of these methods above is actually secure. Again, do not embed these sorts of things in your applications with an assurance they are actually secure.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...