GithubHelp home page GithubHelp logo

pakhee / cross-platform-aes-encryption Goto Github PK

View Code? Open in Web Editor NEW
317.0 16.0 153.0 68 KB

Basic cross platform AES encryption

License: Apache License 2.0

Java 19.54% C# 15.53% Objective-C 32.79% JavaScript 32.14%

cross-platform-aes-encryption's People

Contributors

dependabot[bot] avatar invalidred avatar kalpeshtalkar avatar micromaomao avatar navneet83 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cross-platform-aes-encryption's Issues

"+" sign in the encrypted string

Hi there

I am developing an app where the username/password should be encrypted on android device and decrypted on .net web service. The issue is that some time I'm getting the plus '+' sign in the encrypted string which leads to error. Is that normal ? how to get rid of it without breaking the app ? I'm using the same public key and IV on app and server.

Thanks.

IV generation is questionable

You've commented that the secure random is broken on many platforms - how about including the fix in the IV generation code?

Encrypted and Decrypting in IOS

13 th Character of Decrypted text differ from plain Text when decrypt the same Encrypted text in C# 13 to 17 character get changed , How can I fix This

Same Key and IV used in the three Platforms java,Objective C and C#

Android with C#

Hi,

Thank you for your great lib, I used this with android client and asp.net server,but I am unable to decrypt message in the server. I use the method

CryptLib.SHA256("16 characters", 32);

when I decrypt in the server, please help me to check.
thanks

crypto-js

Is anyone test with crypto-js ? I can not handle within.

Getting decrypted data using CryptLib

// My testing string is "This is test Encryption String Two"

NSString *str=[[NSBundle mainBundle] pathForResource:@"data" ofType:@"rtf"];
NSData *data = [NSData dataWithContentsOfFile:str];

NSString *iv = @"VFSGlobalApp";
NSString *key = [[CryptLib alloc]sha256:@"VFSGlobalApp" length:31];//getHashSha256(@"VFSGlobalApp", 31); //32 bytes

NSData *dataencrypt = [[CryptLib alloc]encrypt:data key:key iv:iv];
NSData *base64 = [dataencrypt base64EncodedDataWithOptions:0];
NSString *sBase64 = [[NSString alloc] initWithData:base64 encoding:NSUTF8StringEncoding];
NSLog(@"Base64 String: %@",sBase64);

NSData *datadecrypt = [[CryptLib alloc]decrypt:dataencrypt key:key iv:iv];
NSString *sDecrypt = [[NSString alloc] initWithData:datadecrypt encoding:NSUTF8StringEncoding];
NSLog(@"Decrypted Data: %@",sDecrypt);


Decrypted Data: {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
{\fonttbl\f0\fmodern\fcharset0 CourierNewPSMT;\f1\froman\fcharset0 TimesNewRomanPSMT;}
{\colortbl;\red255\green255\blue255;\red163\green21\blue21;}
\margl1440\margr1440\vieww9000\viewh8400\viewkind0
\deftab720
\pard\pardeftab720

\f0\fs20 \cf2 This is test Encryption String Two
\f1\fs24 \cf0
}


Please help me out.

Android and C# Encryption & Decryption is not working !

Hello,

As per the code I need to Decrypt the Android Encrypted string in C# we have the exception called
"Padding is invalid and cannot be removed."

For android

        CryptLib _crypt = new CryptLib();
        String output = "";
        String plainText = "Madhav";
        String key = CryptLib.SHA256("Test", 32); // 32 bytes = 256
        String iv = CryptLib.generateRandomIV(16); // 16 bytes = 128 bit
        output = _crypt.encrypt(plainText, key, iv); // encrypt
        System.out.println("encrypted text=" + output);

For c#

        CryptLib _crypt = new CryptLib ();
        String iv = CryptLib.GenerateRandomIV (16); //16 bytes = 128 bits
        string key = CryptLib.getHashSha256("Test", 32); //32 bytes = 256 bits
        Console.WriteLine ("Plain text =" + _crypt.decrypt ("Android Encryption String", key, iv));

"Android Encryption String" = Encrypted string from Android Code , as above.


Now i have tried with reverse Like i need to decrypt C# encrypted string in Android , it also give me exception called.
"javax.crypto.BadPaddingException: EVP_CipherFinal_ex"

For C#

        CryptLib _crypt = new CryptLib ();
        string plainText = "Madhav";
        String iv = CryptLib.GenerateRandomIV (16); //16 bytes = 128 bits
        string key = CryptLib.getHashSha256("Test", 31); //32 bytes = 256 bits
        String cypherText = _crypt.encrypt (plainText, key, iv);
        Console.WriteLine ("iv="+iv);
        Console.WriteLine ("key=" + key);
        Console.WriteLine("Cypher text=" + cypherText);

For android

        CryptLib _crypt = new CryptLib();
        String output = "";
        String key = CryptLib.SHA256("Test", 32); // 32 bytes = 256
        String iv = CryptLib.generateRandomIV(16); // 16 bytes = 128 bit
        output = _crypt.decrypt("C# Encryption String", key, iv); // decrypt

"C# Encryption String" = Encrypted string from C# Code , as above.

Can you please check this if i have done anything wrong , can you please guide me for that ,
that will be appreciable.

Thanks in Advance
Madhav

iOS how to use generateRandomIV?

In iOS, generateRandomIV() returns NSData, not NSString. So I tried some ways to convert the NSData to NSString but fail.

I'm using Swift 2.x with Objc Bridge Headers to include CryptLib.m/h and NSData+Base64.m/h. Here's the code:

Method 1

let data = aes256encrypter.generateRandomIV(16)
let iv = data.base64EncodedStringWithOptions(.EncodingEndLineWithCarriageReturn)
print(iv)

It prints out something like Zo8sin4RHrj77WWc5LV3xw==, which is not the length I want

Method 2

let data = aes256encrypter.generateRandomIV(16)
let iv = String(data: data, encoding: NSUTF8StringEncoding) 

It becomes nil now.

So how to get a random IV in iOS? It's really easy to generate random IV in java using the same API. Why isn't generateRandomIV() in iOS returns a NSString instead of NSData?

Decryption not working in iOS. Encrypted in C#. Works in Android

Hi there,

I try to use your library classes to encrypt and decrypt some strings that are shared between apps.
I'm using C# to create a Hybrid app with one code base for iOS and Android.
So the encryption is done in C#.
That's working fine that way:

CryptLib crypto = new CryptLib();
string iv = CryptLib.GenerateRandomIV (16); //Hash of 128 bits
string key = CryptLib.getHashSha256 (KEY,32); //256 bits
string encryptedText= crypto.encrypt (textToEncrypt, key, iv);

After that I cut the encrypted text into half and put the iv in. On that way I'm able to read the used iv from other apps that share the value with the encrypting app.

In Android, that's working pretty fine that way:

//The key of the encryption
String key = "MYKEYUSEDBEFORE";
//Cut out the iv that was used in encryption
int end = encryptedText.length()/2+8;
int start = end-16;
String iv = encryptedText.substring(start,end);
//Remove the iv from the encryptedText
encryptedText = encryptedText.replace(iv, "");
try
 {
    //decrypt and return the decryptedText
    key = CryptLib.SHA256(key, 32);
    CryptLib crypto = new CryptLib();
    String result = crypto.decrypt(encryptedText, key, iv);
    return result;
}
catch(Exception ignored){}

return null;

That's working perfect. I receive my text without problems.
I try the same approach in iOS that way:

int end = [encryptedText length]/2+1;
int start = end - 9;
//Get key
NSString *key = @"MYKEYUSEDBEFORE;
key = [[StringEncryption alloc]  sha256:key length:32];
//Cut out iv from encryptedText
NSString *iv = [encryptedText substringWithRange:NSMakeRange(start, 16)];
//Replace iv in encryptedText
encryptedText = [encryptedText stringByReplacingOccurrencesOfString:iv withString:@""];
//Decyrpt
 NSData *resultData = [[StringEncryption alloc] decrypt:[encryptedText dataUsingEncoding:NSUTF8StringEncoding] key:key iv:iv];
    NSString *result = [[NSString alloc]initWithData:resultData encoding:NSUTF8StringEncoding];
    return result;

But result is always null.

I can confirm that the iv is correct, it's definitely the same as used for encryption and the encryptedText after replacing the iv is exactly the same as after encryption and before putting in the iv.
So, what am I doing wrong?

Thanks a lot!

Best regards

iOS Swift Problem

I have added all files into my Swift Project (CryptLib.h/CryptLib.m/NSData+Base64.h/NSData+Base64.m) and also I have added <UIKit/UIKit.h> to all .h files. Some errors gone but I can not use this class inside my swift classes.

I'd appreciate if anyone could provide some examples in SWIFT cause most of programmers are using SWIFT nowadays.

Thanks...

Not working in IOS. Please check before using.

Hi,

We need to encrypt/decrypt string between IOS,android and C# app.We have used this class and it works in C# and android but not working in IOS. Please check for IOS compatibility before use.

Regards

Need Support for Node.js

It will be great to provide support for node.js web services primarily built on express.js framework. Let me know if i could contribute.

C# code and Objective C code gives two different set of results

We have followed exactly the same approach given here for IOS and C#. But unfortunately we are getting two different results.

We hardcoded IV key and Secret key and tested. Even this scenario into different results.

Let us know that any one has resolved this issue.

Any help is appreciated.

Thanks in advance

Decryption is not working on iOS but working fine in Android and Java server.

Hi,
I'm using this library in iOS App, as well as our Android team, but at Java server its receiving the encrypted request, but when they decrypt it, its getting error "Bad padding exception: Given Final Block Not Properly Padded", but its working fine on Android.
I'm also getting a response, but the data is not Decrypting. And at Android its working fine as they use same android code on Java servers. But it's not supporting me, can you kindly help me with it.
Thanks,

Same IV and key using at JAVA server,android and IOS [hardcoded for testing].
NSString* const IV = @"288dca8258b1dd7c";
NSString* const key = @"c292a6e6c19b7403cd87949d0ad45021";

My approach as in CryptLib.m

//encrypt

  • (NSString_) encryptString:(NSString_)XMLRequest withKey:(NSString *)key
    {
    NSData * encryptedData = [[StringEncryption alloc] encrypt:[XMLRequest dataUsingEncoding:NSUTF8StringEncoding] key:key iv:IV];
    NSString * encryptedXML = [encryptedData base64EncodingWithLineLength:0];

     return encryptedXML;
    

    }

//decrypt

  • (NSData_) decryptData:(NSData_)XMLResponse withKey:(NSString *)key
    {
    NSString *responseString = [[NSString alloc] initWithData:XMLResponse encoding:NSUTF8StringEncoding];
    NSLog(@"responseString--------------------------%@",responseString);

    //

    NSData * decryptedData = [[StringEncryption alloc] decrypt:XMLResponse key:key iv:IV];

    //

    NSString * decryptedXML = [[NSString alloc] initWithData:decryptedData encoding:NSUTF8StringEncoding];
    NSLog(@"decrypted data:: %@", decryptedXML);

    return decryptedData;
    // this data sent for xml parsing
    }

New line character in encoding-decoding methods

Hi,

you library works fine but in my Android Application (API Level 22) when I'm try to encode a string I get one which contains "new line" characters \n; I'm using my static passphrase instead a SHA or MD5 generator functions.

I'm looking into your code and I find in encryptDecrypt() function at lines 154 and 163 the DEFAULT setting for Base64 enconde; I try to change this value this with Base64.NO_WRAP (from Base64.java doc: "Encoder flag bit to omit all line terminators (i.e., the output will be on one long line)").

With this fix the encoding works fine (without new line characters).
Do yo try to test your library with this setting?

Thank you!
Cheers

Encrypt in java and Decrypt in IOS - Not working

I am trying to compile this pkg in IOS it doesn't compile . But if I add

  • (NSString *) base64EncodingWithLineLength:(unsigned int) lineLength ;

In NSData+Base64.h programpile

But when I use

NSString * _secret = @"This the sample text has to be encrypted"; // this is the text that you want to encrypt.
NSString * key = @"shared secret"; //secret key for encryption. To make encryption stronger, we will not use this key directly. We'll first hash the key next step and then use it.
NSString * _key = [[StringEncryption alloc] sha256:key length:32]; //this is very important, 32 bytes = 256 bit
NSString * iv = [[[[StringEncryption alloc] generateRandomIV:11] base64EncodingWithLineLength:0] substringToIndex:16];
NSData * encryptedData = [[StringEncryption alloc] encrypt:[_secret dataUsingEncoding:NSUTF8StringEncoding] key:_key iv:iv];
NSLog(@"encrypted data:: %@", [encryptedData base64EncodingWithLineLength:0]); //print the encrypted text

I get coredump

Encryption Problem in Android

Hi, while I am encrypting the string, I am getting blank spaces in encrypted string in android. Please let me know how to fix it.

iOS has different output

Hi. i use this library for Android and IOS in native. it's work fine in Android but in IOS it return different result. i try to encrypt "121212". in Android it return "qu6BVyPREpc5tnV1M1h7rw==" but in IOS it return different output each time.
Thanks

Broken while Decrypt JSON String.

I am using your AES Encryotion for a month, now i have problems when i encrypt my JSON string. It will give us broken JSON String.

Example: {"id": 123, "name": "chonex"} then convert this to AES Encryption. Then, i will put this to JSON String again with a RANDOM IV. This will be like this: {"encrypted" : "asdqwrqtreywetusdmg", "randomIV" : "qrqetyers"}. And pass this to my IOS or Android, But when i decrypt this to ios or android platform, it will be broken. The decryted string will be like:' {"id": 123, "name": "chone ' with missing ' x"}'

Please considered commenting this if you have same issue on mine. thanks

IOS - Swift

Hi, i tried your library in my IOS project *Swift, and it didnt work, not because it is made in OBJC but because of the lack of instructions for IOS about how to install and use, i did a copy of the files in my project and everything went weird, red error messages and yellow ones...

Please add documentation, Thank you.

PHP Support

Can this work on php or are you plainig to provide it on php also.

Issue with decrypting on iOS

Hi,

I have been facing a similar problem as this issue #24

Been using this library for Java Server Side as well as on Android without any issues.

The issue is the string encrypted on Java server is not being decrypted on the iOS side. Where do you think I might be going wrong with this?

Encryption in c# is broken if string to encode contains non English characters (with fix)

Code uses lenght of the input sting but is should use length of array GetBytes returns.
Fixed code should be something like that:
if (mode.Equals(EncryptMode.Encrypt))
{
//encrypt
var encbytes = _enc.GetBytes(inputText);
byte[] cypheredText = _rcipher.CreateEncryptor().TransformFinalBlock(encbytes, 0, encbytes.Length);
_out = Convert.ToBase64String(cypheredText);
}

Decrypt returns wrong text (comparing with the original which encrypted)

I use your code to encrypt/decrypt text.
In c# it works perfect, but in xcode i need some help.
Firstly i make some changes and the encryption works perfect as in c#.
Now i have problem with decryption.
Here is the code of calling:

NSString * secret = @"1234";
    NSString * key = @"mykey";
    NSString * iv = @"myiv";
    NSData * encryptedData = [[CryptLib alloc] encrypt:[secret dataUsingEncoding:NSUTF8StringEncoding] key:key iv:iv];
    NSString *encryptedText = [encryptedData  base64EncodingWithLineLength:0];
    [self showUIAlertWithMessage:encryptedText andTitle:@"ecryption"];

    NSData * decryptedData = [[CryptLib alloc] decrypt:[encryptedText dataUsingEncoding:NSUTF8StringEncoding]  key:key iv:iv];
    NSString * decryptedText = [decryptedData  base64EncodingWithLineLength:0];
    [self showUIAlertWithMessage:decryptedText andTitle:@"decryption"];

and the code from CryptLib:

#import "CryptLib.h"

@implementation CryptLib

- (NSData *)encrypt:(NSData *)plainText key:(NSString *)key  iv:(NSString *)iv {
    char keyPointer[kCCKeySizeAES256];// room for terminator (unused) ref: https://devforums.apple.com/message/876053#876053
    char ivPointer[kCCBlockSizeAES128];
    BOOL patchNeeded;
    bzero(keyPointer, sizeof(keyPointer)); // fill with zeroes for padding
    bzero(ivPointer, sizeof(ivPointer));
    patchNeeded= ([key length] > kCCKeySizeAES256+1);
    if(patchNeeded)
    {
        NSLog(@"Key length is longer %lu", (unsigned long)[key length]);
        key = [key substringToIndex:kCCKeySizeAES256]; // Ensure that the key isn't longer than what's needed (kCCKeySizeAES256)
    }

    [key getCString:keyPointer maxLength:sizeof(keyPointer) encoding:NSUTF8StringEncoding];
    [iv getCString:ivPointer maxLength:sizeof(ivPointer) encoding:NSUTF8StringEncoding];

    NSUInteger dataLength = [plainText length];

    //see https://developer.apple.com/library/ios/documentation/System/Conceptual/ManPages_iPhoneOS/man3/CCryptorCreateFromData.3cc.html
    // For block ciphers, the output size will always be less than or equal to the input size plus the size of one block.
    size_t buffSize = dataLength + kCCBlockSizeAES128;
    void *buff = malloc(buffSize);

    size_t numBytesEncrypted = 0;
    //refer to http://www.opensource.apple.com/source/CommonCrypto/CommonCrypto-36064/CommonCrypto/CommonCryptor.h
    //for details on this function
    //Stateless, one-shot encrypt or decrypt operation.
    CCCryptorStatus status = CCCrypt(kCCEncrypt, /* kCCEncrypt, etc. */
                                     kCCAlgorithmAES128, /* kCCAlgorithmAES128, etc. */
                                     kCCOptionPKCS7Padding, /* kCCOptionPKCS7Padding, etc. */
                                     keyPointer, kCCKeySizeAES256, /* key and its length */
                                     ivPointer, /* initialization vector - use random IV everytime */
                                     [plainText bytes], [plainText length], /* input  */
                                     buff, buffSize,/* data RETURNED here */
                                     &numBytesEncrypted);
    if (status == kCCSuccess) {
        return [NSData dataWithBytesNoCopy:buff length:numBytesEncrypted];
    }

    free(buff);
    return nil;
}

-(NSData *)decrypt:(NSData *)encryptedText key:(NSString *)key iv:(NSString *)iv {
    char keyPointer[kCCKeySizeAES256];// room for terminator (unused) ref: https://devforums.apple.com/message/876053#876053
    char ivPointer[kCCBlockSizeAES128];
    BOOL patchNeeded;
    bzero(keyPointer, sizeof(keyPointer)); // fill with zeroes for padding
    bzero(ivPointer, sizeof(ivPointer));
    patchNeeded = ([key length] > kCCKeySizeAES256+1);
    if(patchNeeded)
    {
        NSLog(@"Key length is longer %lu", (unsigned long)[key length]);
        key = [key substringToIndex:kCCKeySizeAES256]; // Ensure that the key isn't longer than what's needed (kCCKeySizeAES256)
    }

    [key getCString:keyPointer maxLength:sizeof(keyPointer) encoding:NSUTF8StringEncoding];
    [iv getCString:ivPointer maxLength:sizeof(ivPointer) encoding:NSUTF8StringEncoding];

    NSUInteger dataLength = [encryptedText length];

    //see https://developer.apple.com/library/ios/documentation/System/Conceptual/ManPages_iPhoneOS/man3/CCryptorCreateFromData.3cc.html
    // For block ciphers, the output size will always be less than or equal to the input size plus the size of one block.
    size_t buffSize = dataLength + kCCBlockSizeAES128;

    void *buff = malloc(buffSize);

    size_t numBytesEncrypted = 0;
    //refer to http://www.opensource.apple.com/source/CommonCrypto/CommonCrypto-36064/CommonCrypto/CommonCryptor.h
    //for details on this function
    //Stateless, one-shot encrypt or decrypt operation.
    CCCryptorStatus status = CCCrypt(kCCDecrypt,/* kCCEncrypt, etc. */
                                     kCCAlgorithmAES128, /* kCCAlgorithmAES128, etc. */
                                     kCCOptionPKCS7Padding, /* kCCOptionPKCS7Padding, etc. */
                                     keyPointer, kCCKeySizeAES256,/* key and its length */
                                     ivPointer, /* initialization vector - use same IV which was used for decryption */
                                     [encryptedText bytes], [encryptedText length], //input
                                     buff, buffSize,//output
                                     &numBytesEncrypted);
    if (status == kCCSuccess) {
        return [NSData dataWithBytesNoCopy:buff length:numBytesEncrypted];
    }

    free(buff);
    return nil;
}

Decryption result getting null in IOS

i am using this code for encrypt and decryption
NSString * _secret = @"Ashish";           NSString * _key = @"1234";          NSData * encryptedData = [[StringEncryption alloc] encrypt:[_secret dataUsingEncoding:NSUTF8StringEncoding] key:_key iv:@"WLCOU32wBQnUDdw="];           NSLog(@"encrypted data:: %@", [encryptedData  base64EncodingWithLineLength:0]); //print the encrypted text           encryptedData = [[StringEncryption alloc] decrypt:encryptedData  key:_key iv:@"WLCOU32wBQnUDdw="];          NSString * decryptedText = [[NSString alloc] initWithData:encryptedData encoding:NSUTF8StringEncoding];      NSLog(@"decrypted data:: %@", decryptedText); //print the decrypted text
encryption result getting properly but decryption result getting null.How can we resolved that?
i am just checking with hard code data in both android and ios but its working properly in android.

Invalid encryption in c# with a string "ñ"

{
"Encrypted":"vQpHZRu60M6SK0Yxjm9HfAy86e8UeaVztyB5GQdMblJ7aOkSO4LwgFlIAIX5WtEuF0CgBZO4fOZJTkAH5KtuIpxB6g7f4bwMj/XiNjD9eXJcwN2h9r02Yv5s4TIG7RsWXvNIGVPrege6B0t5tSIXeAHYEM5+JiqdtBgC74a+ogFK+0MUToj3shEsG0itUVq0hACAAz11HzBnhNSpc9jTKxGkmBPpCBAs9OOJ83IAOm1Gh0XmwBXyKVd50ueiHCuEpjoJ0FEK5Dnl73+XitdS/HJUWH2QleEPZs7HejFNRvb7u/RSViLkzRhWnRAbBTY9",
"Iv":"xwp5H7XV95ekvF6m"
}

This is response from c# wcf service. We figure out that when the data have "ñ" , the encryption is incomplete.

Array Index Out of Bound Bug Issue

I have noticed that array inbuf in method (id) initWithBase64EncodedString:(NSString *) string of file NSData+Base64.m is decleared with unsigned char inbuf[3]. However, code in line 79 uses out-of-bound array index:

outbuf [2] = ( ( inbuf[2] & 0x03 ) << 6 ) | ( inbuf[3] & 0x3F ); //inbuf[3] is out-of-bound

I think array inbuf should be declared as unsigned char inbuf[4] to prevent array out-of-bound access violation.

Typo Issue

Function Parameter name is different while String used in function is different

public static final String md5(final String inputString) {

while used one is
digest.update(s.getBytes());

change it to
digest.update(inputString.getBytes());

Please update your code.

Thanks

Android and C# getHashSha256 Difference

First of all thanks for the great library
This is actually not a big issue but on how to use section

Android hashes the key as follows;
string key = CryptLib.getHashSha256("my secret key", 31);
C# hashes as follows;
String key = CryptLib.SHA256("my secret key", 32); //32 bytes = 256 bit

Which gave us at the beginning different results then I have changed the C# code to use 32bytes and results were identical.

It does not work for iOS

i have a one c# web service and i can decript and encript c# webservice, android project and c# client project. but i can not implement pakhee ios code for my ios application. There are a lot of error in ios classes. Could you fix ios classes and give usage example for ios application?

Swift (2.0) errors and warnings (Not working)

Hey guys,

I wanted to try this cross-platform encryption and realized that it is not working with swift (2.0).
There are a few errors and warnings.

  1. The errors in CryptLib.h can be fixed by importing UIKit:

import < UIKit/UIKit.h > //Remove whitespaces

In NSData+Base64 I get two warnings and one error I can't fix.

  1. Warning: "Method definition for 'dataFromBase64String:' not found"

  2. Warning: "Array index 3 is past the end of the array (which contains 3 elements)

     outbuf [2] = ( ( inbuf[2] & 0x03 ) << 6 ) | ( inbuf[3] & 0x3F );
    
  3. Error: "'autorelease' is unavailable: not available in automatic reference counting mode'

Maybe someone can help me?

Upadte 1: I fixed the Error by turning off the "Objective-C Automatic Reference Counting" in my Build Settings

Error in "HowToUse.cs"

Hello,
I think there's a typo in "HowToUse.cs"
At line 7

string key = CryptLib.getHashSha256("my secret key", 31);

There is "31": this causes a wrong padding exception in asp.net c# code.
I was testing encryption on Android side and decryption on C# server-side.
Using value "32" everything works fine.

iOS swift version

Hi,
i want iOS library in swift language version. Is it there ?

thanks for help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.