Jump to content

Stuck on 2 problem. Need HELP.

- - - - -

  • Please log in to reply
4 replies to this topic

#1
Onlyorange

Onlyorange

    Newbie

  • Members
  • Pip
  • 4 posts
First one is :
takes a string from input in the format <integer1><operation><integer2> and prints an integer result based on the operation as follows (example i/o in parentheses):

a: the sum plus six (input: 2a3 output: 11)
b: twice the sum (input: 2b3 output: 10)
c: 100 minus the product (input: 2c3 output: 94)

And also this program needs to be easy to add new operations as the need arises, possibly hundreds of them.

Second :
program that can be used to verify that a message that ran through the program on one computer has not been altered in transit to another computer which uses the same program. I finished code the mode of transit - But I can't figure that a program to guarantee that a message has not changed between its generation and its reception.:crying:

Can anyone help me with these 2 problems?

Thanks.

#2
Arctic Fire

Arctic Fire

    Learning Programmer

  • Members
  • PipPipPip
  • 48 posts
App 1:

You could try making it modular. For each operation you perform, have a class that does the operation and dynamically load it.

Java - Dynamic loading of class and jar file | twit88.com

Then, you could add new operations by simply pushing out new jar files to the clients. (in a situation where a project is distributed to other users.)

App2:

Try public key cryptography. Sign the message with the private key and check integrity with the public key.

Edited by Arctic Fire, 11 November 2010 - 10:34 AM.


#3
Onlyorange

Onlyorange

    Newbie

  • Members
  • Pip
  • 4 posts
Thanks.
Just got done with first one.
And second one still seems tricky to me...:(

#4
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
The file class in java has a .setReadOnly() method.
... i think the javadoc is wrong there, it says public boolean setReadyOnly(), which i think must be public void setReadOnly(boolean readOnly)

If that is not secure enough for your liking, i gues you'll need to work with the lastmodified() stuff. Offcourse other programs can set it again so you'll need an extra protection for this by..
maybe let the first line of the file be a hash of the lastmodified. The receiving program will hash the lastmodified() of the file with the same algorithm.
If the hash turns out to be the same as the first line then you can consider it did not change.
...Unless whatever program opened the file between the transition also knows the hashing algorithm, which is very unlikely.

#5
Arctic Fire

Arctic Fire

    Learning Programmer

  • Members
  • PipPipPip
  • 48 posts
How about something like this?

Generating a Message Authentication Code (MAC) | Example Depot

EDIT:

This is a better guide IMO.

MAC:
InformIT: Cryptography with Java > Message Authentication Code

Public Key Signature:
InformIT: Cryptography with Java > Digital Signature

Edited by Arctic Fire, 11 November 2010 - 05:49 PM.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users