I have two files like this:
Client.java:
public class Client implements Runnable {
//code
public void run() {
//more code
Crypt cls = new Crypt();
cls.decrypt(request,key,type);
//print "val" here.
//more code
}
}
And then the Crypt.java file which is like this:
public class Crypt{
public static byte[] decrypt(byte[] val, byte[] key, int type)
{
//val assigned here
// the following is used to assign it.
val[length - len - 1] ^= key[8 + (((byte)(key[8 + b] + key[8 + a])) & 0xFF)];
return val;
}
}
I need to be able to access the val variable in in the Client.java file again after it has run through the Crypt.java file.
I've tried cls.val
and cls.decrypt.val
but I don't know how to get it working.
Thanks for the help!
Your dycrypt()
method in class Crypt
is a static
member of the Crypt
class. So you don't need to create an instance of Crypt
class in Client
class like -
Crypt cls = new Crypt();
cls.decrypt(request,key,type);
You can just call the decrypt()
method using the class name and store the returns into a byte[]
array -
byte[] vals = Crypt.decrypt(request, key, type);
Then using a for loop/for-each loop you can print the vals
array -
for(byte each : vals){
System.out.println(each);
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments