DES encryption in Rubymotion

106 views Asked by At

How can I encrypt/decrypt a string with DES algorithm on iOS using Rubymotion?

There are very few examples even on Obj-C, and they are hardly translatable to Rubymotion.

1

There are 1 answers

0
DarkSun On BEST ANSWER

I had to install CommonCrypto pod.

After I used this code to encrypt with DES:

string = "string to encrypt"
data = params.dataUsingEncoding(NSUTF8StringEncoding)

errorPtr = nil # You can use a real error object here if you need
encrypted_data      = data.DESEncryptedDataUsingKey(User.first.key, error: errorPtr) 

Also you can check other aviable encryption and decryption methods in /vendors/Pods/CommonCrypto/NSData+CommonCrypto.m file.