2

I need to encrypt and decrypt NSStrings. It doesn't have to be secure (at all!) just unreadable to an average user. Something as simple as a shift cipher would work alright, but I would like an algorithm slightly less obvious to the user.

Is there something built in to the iOS sdk that does this already? Maybe RSA encryption? Or a simple to code algorithm that wouldn't look like a one to one character exchange? Thank you!

4 Answers 4

1

How about Base64.

It's completely non-secure, and although unreadable it will be a fairly obvious encoding scheme for anyone remotely knowledgeable in IT.

Implementation details : How do I do base64 encoding on iphone-sdk?

Sign up to request clarification or add additional context in comments.

Comments

1

What about ROT13? It was already used in ancient Rome, fun to use, not save.

Or use string encoding as used for URLs in web technologies.

Comments

1

You could use a substitution cypher. Just prepare a 255 byte array with indexes from 1 to 255, scramble the array and replace each byte with the corresponding index value. Another easy cypher employs a key of length N, consisting of positive and negative offsets. Each byte of the nsstring gets shifted - the first by the value of the first offset, the second by the second and the k-th by the value of the (k mod N)-the. It is much harder to spot for the average, unmotivated user, and almost as easy to implement as a single shift cypher.

Comments

1

As well as the other suggestions, you could also try Vigenère, which seems to meet your design criteria: simple and unreadable.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.