Sometimes there is a need to implement an algorithm for encryption/decryption on strings, files or other data in your Swift project. Conversion for this type of algorithms from other languages (such as Java) to Swift, unfortunately is not straight forward.

Unicode Scalars

Behind the scenes, Swift’s native String type is built from Unicode scalar values. A Unicode scalar is a unique 21-bit number for a character or modifier, such as U+0061 for LATIN SMALL LETTER A ("a") , or U+1F425 for FRONT-FACING BABY CHICK ("🐥")

In Swift a Character can be constructed from a UnicodeScalar value. And we can build a UnicodeScalar from an Int. …

About

Gorjan Shukov

iOS Engineer | more info about me @ shukov.site

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store