Home:ALL Converter>CryptLib decryption returns wrong value

CryptLib decryption returns wrong value

Ask Time:2017-05-30T17:32:13         Author:Randi

Json Formatter

I am using Cross-Platform-AES for my AES encryption/decryption within my swift app. My encryption is working fine. But when I try to decrypt the service returns value it doesn't give me the correct result. Here how I am doing decryption.

public func decryptStrings(text:String)->String{

    let hashKey=cryptoLib.sha256(key, length: 31)
    let decryptedData = cryptoLib.decrypt(text.data(using: String.Encoding.utf8), key: hashKey, iv: iv)
    let decryptedString=decryptedData?.base64EncodedString()
    print("decryptedString \(decryptedString! as String)")
    return decryptedString!

}

Please explain me how can I decrypt this in correct way. Thanks

ENCRYPTION

public func base64Convertion (secretcode:String)->String
{


    let hashKey=cryptoLib.sha256(key, length: 31)
    let encryptedData=cryptoLib.encrypt(secretcode.data(using: String.Encoding.utf8), key: hashKey, iv: iv)
    let encryptedString=encryptedData?.base64EncodedString()
    print("encryptedString \(encryptedString! as String)")


    return encryptedString!

}

Author:Randi,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/44258550/cryptlib-decryption-returns-wrong-value
yy