-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can i use it in Swift 5 or 4 #62
Comments
I am unable to use this method "- (NSData *)encrypt:(NSData *)plainText key:(NSString *)key iv:(NSString *)iv" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In java they use this class now I want to use it in ios swift
public class CryptLib {
// System.out.println(_out);
return _out; // return encrypted/decrypted string
}
// * @param _iv
* initialization Vector
* @return returns encrypted (cipher) text
* @throws InvalidKeyException
* @throws UnsupportedEncodingException
* @throws InvalidAlgorithmParameterException
* @throws IllegalBlockSizeException
* @throws BadPaddingException
*/
// return encryptDecrypt(_plainText, _key, EncryptMode.ENCRYPT, _iv);
String key = _key;
try {
key = SHA256("HALTech^%$#@!Trn", 32);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
// * @param _iv
* initialization Vector
* @return encrypted value
* @throws InvalidKeyException
* @throws UnsupportedEncodingException
* @throws InvalidAlgorithmParameterException
* @throws IllegalBlockSizeException
* @throws BadPaddingException
*/
public String decrypt(String _encryptedText, String _key)
throws InvalidKeyException, UnsupportedEncodingException,
InvalidAlgorithmParameterException, IllegalBlockSizeException,
BadPaddingException {
String key = _key;
try {
key = SHA256("HALTech^%$#@!Trn", 32);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return encryptDecrypt(_encryptedText, key, EncryptMode.DECRYPT, _key);
// return encryptDecrypt(_encryptedText, _key, EncryptMode.DECRYPT, _iv);
}
}
The text was updated successfully, but these errors were encountered: