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.
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
. …