as I’m a newbie in this field the question may seem to be so stupid, but please forgive me. I want to achieve SHA-512 in Objective-C for an equivalent Java code..Here is the Java Code :
String passwordSalt = "Somesalt";
byte[] bsalt=base64ToByte(passwordSalt);
byte[] passwordToDigestAsBytes=("somepassword").getBytes("UTF-8");
MessageDigest digest = MessageDigest.getInstance("SHA-512");
digest.reset();
digest.update(bsalt);
byte[] = input digest.digest(passwordToDigestAsBytes);
I’m using CC_SHA512 for digest function…but what I need to do for digest.update(bsalt) part? how can I achieve the same functionality in Objective-C?
I’m not familiar with Java’s
MessageDigestobject, but it looks like it’s just prepending the salt before the data, which is a very normal way to process this kind of data. So you’d just callCC_SHA512_Update()twice. Once with the salt, and then a second time with the password data. Then you’d callCC_SHA512_Final()to fetch the result.