I made a program, and for "protection" set some parameters. First parameter is date to wich program can work (something Trial but with fixed date), and the second one is HDD serial number (had some problems with other hardware serials) on which program works.
Now, I need to make it possible to me to change these values after compiling program.
I tried adding Log in which accepts anything and executes program with default values. Only if I log in with my user/pass values, it somehow allows me to change default values. After that, by every start of program, he checks with new values I've entered earlier.
If someone understands what I want and what I tried, tell me is this possible, or is there some other and easier/better solution?
put your "constant" part in a String which will must have a fixed size
that string should have only ASCII code; for max flexibility I'd use a base64 encoded string, so you can put even binary encripyted data
compile the class
if you open the .class with an hexadecimal editor, you are able to see and change that string
edit the .class file by that hexadecimal editor, putting the new ASCII values. Keep attention not to change the size of the String
Note also that this approach can be hackable by some guys :)
Related
I am implementing a simple MIPS simulator using java. My problem is in the fetching instruction step where I should take one instruction and convert it to 32-bit binary code to be able to determine that the first 6 bits are the opcode and the next 5 are the rs(source register) and so on.
At first I thought I would just make an arraylist and add the 15 instructions my program is going to support and then make another arraylist and add the 32 registers available and then when the user enters his code I loop on the entered string comparing it with my instructions and registers names in the arrays, but then I realized I don't know which characters exactly I am going to compare from the users code I mean (add $s1 $s4 $s5) will be different from (addi $t8 $zero 1) so I can't just check the substring of the first 3 characters every time with the instructions array and then check the next 3 because as you see the zero register might take a larger place and so on.
My second approach is to define the instructions by their opcodes and the registers by their binary values then convert the given instruction by the user to binary and compare it. Is there any other possible or probably easier ways to do so?
If I understand you right, your question is how to get from the user's assembler code to the machine code that is interpreted by your MIPS. This is where tokenizers come in handy. Use a StringTokenizer (http://docs.oracle.com/javase/7/docs/api/java/util/StringTokenizer.html) to convert user input into a string of byte code and feed the latter one to your MIPS exactly how you propose in your question.
I know if I run a program, it will likely express one way or another: what it is expecting from each variable. But I would like to determine on my own when I read over each page of Android code etc. e.g:
How could I determine what size or length an android program is expecting a string array to be?
Whether an integer or double, is expected to be positive or negative?
etc.
Help in this regard would be much appreciated.
You can set breakpoints in your code and examine all of the variables when the program pauses. This would give you a general idea of whether the integers were positive or negative, the length and content of the strings, etc. It could be useful if the code was poorly documented.
Assuming you are using Android Studio you can follow this guide:
https://developer.android.com/tools/debugging/debugging-studio.html
I have a hashMap(guava bimap) in which keys and values both are strings, I wanted to write a program which parses the given file and replaces all the strings in the file which are also in BiMap with corresponding values from Bimap.
for example: i have a file called test.txt has following text
Java is a set of several computer software and specifications developed by Sun Microsystems.
and my BiMap has
"java i" => "value1"
"everal computer" => "value2" etc..
So now i want my program to take test.txt and Bimap as input and give an output which looks something like this
value1s a set of svalue2 software and specifications developed by Sun Microsystems.
please point me towards any algorithm which can do this, the program takes large files as input so brute force may not be a good idea.
Edit: I'm using fixed length strings for keys and values.
That example was just intended to show the operation.
Thanks.
For a batch operation like this, I would avoid putting a lot of data into the memory. Therefore I'd recommend you to write the new content into a new file. If the file in the end must be the exact same file, you can still replace one file by the other, at the end of the process. read, write and flush each new line separately, and you won't have any memory issues.
I want to write a reversible Encoder along with the corresponding Decoder, so that any string may be encoded to a legal file name corresponding to file naming rules of the Unix file system.
How to achieve this?
Example:
"xyz.txt" would be a valid file name, while "xyz/.txt" would not.
tl;dr: Your approach is flawed. Stick with the limitations of the file system. They're pretty hard to gracefully overcome (especially without introducing your own, even weirder limitations).
It's not possible to make one that is strictly decodable. You're trying to map a larger domain to a smaller domain which means that the reverse mapping cannot be known-correctly reversible.
This is easy to demonstrate with a simple example: how do you encode / such that it can be reversed? "Easy," you might say, "I'll just replace with the token x." But now how do you know when an x is an actual x and when your x is a 'special' x that should be converted to /? You can't.
You can of course make a system that is very unlikely to have any accidental clashes. For example, rather than changing / to - (which would be very error prone), you could change it to ---.
Oh, also, for what it's worth, most unix file systems actually consider any characters other than / or a null char a valid character (more). Obviously using that is a pain in the ass though.
I'm using a program (klee) that give me tests of c code.
I need to use the results in my program.
It is not readable information, but some of the solutions are hexadecimal data with the next format:
'\x0e\x00\x00\x00'
I have already asked about how to convert it into integer, and I found the solution.
I will have to introduce this kind of results in structs too, I will know the size but any about the fields or anything else about it.
I think I can solve this but now the problem is that sometimes you can obtain things like:
'\n\x00\x00\x00'= 13
or
'\r\x00\x00\x00' = 10
And I didn't found which kind of representation they use to convert it in readable information..
Apparently I could solve this in python with:
import struct
selection = struct.unpack('
I don't have any idea of pyton, and I would like found a solution in java or c.
Thanks very much
The value \n\r is used by Windows systems to indicate a newline - the \n moves to the new line, and \r moves the write pointer to the start of the line. I'm thinking that you might have had some character data containing a newline where each character was converted into a 32-bit integer value in big-endian format.
Hope this helps!