Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
    Bookmark Topic Watch Topic
  • New Topic

Continue for my problem(plz help me in)

 
Mohammad Ahmad
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Report post to moderator
no i have implemented it from my own not by using what is available in the JDK ...the problem is as following:
**the input of my program is the message string which i need to calculate the digest for...
**the output of my program is the Digest
now the output(Digest) must be 160 bit(20 characters)the problem is with using files :
i defined two files one to store my input message the other is for holding the output(Digest) and i have problem in both these files:
for the input file which i put in it the message string when i pass this file name to my program to read the message it gives me every time the same digest even if i change the content of this file in other word i changed the message it self...but if i pass to my program the message string it self not the file name which contains the message it gives mr=e the right answer:

System.out.println ("The Program is Reading Your input Message to calculate the Digest");
try{
FileInputStream Message_File=new FileInputStream ("C:/JBuilder4/lib/input.txt");
BufferedReader buff=new BufferedReader(new InputStreamReader(Message_File));

System.out.println("The resulted Digest in base64 form for the Input_Message =" +Base64_SHA1_Encoding("Message_File"));-->it gives here same digest to all strings

the second problem is with the output file:
when i print the result on the screen using JBuilder it gives me the right result which it is digest of 20 characters but when i want wrote it into a file and i opened the file i find only 19 characters not 20 and if my message was long it gives me something like this |||||||
so for example when i print the result i got this digest:
�#?.?�?Y2??Y2?? ?- but when i open the file i see only 19 charactes there is a missing symbol or i see if the message is longno i have implemented it from my own not by using what is available in the JDK ...the problem is as following:
**the input of my program is the message string which i need to calculate the digest for...
**the output of my program is the Digest
now the output(Digest) must be 160 bit(20 characters)the problem is with using files :
i defined two files one to store my input message the other is for holding the output(Digest) and i have problem in both these files:
for the input file which i put in it the message string when i pass this file name to my program to read the message it gives me every time the same digest even if i change the content of this file in other word i changed the message it self...but if i pass to my program the message string it self not the file name which contains the message it gives mr=e the right answer:

System.out.println ("The Program is Reading Your input Message to calculate the Digest");
try{
FileInputStream Message_File=new FileInputStream ("C:/JBuilder4/lib/input.txt");
BufferedReader buff=new BufferedReader(new InputStreamReader(Message_File));

System.out.println("The resulted Digest in base64 form for the Input_Message =" +Base64_SHA1_Encoding("Message_File"));-->it gives here same digest to all strings

the second problem is with the output file:
when i print the result on the screen using JBuilder it gives me the right result which it is digest of 20 characters but when i want wrote it into a file and i opened the file i find only 19 characters not 20 and if my message was long it gives me something like this |||||||
so for example when i print the result i got this digest:
�#?.?�?Y2??Y2?? ?- but when i open the file i see only 19 charactes there is a missing symbol or i see if the message is long ||||||||
so where the problem may be???i need a serious help plz...
--------------------------------------------------------------------------------

so where the problem may be???i need a serious help plz...
--------------------------------------------------------------------------------
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please continue threads under their original topic, instead of starting new ones. Thanks!

(I've added the above information to the original thread.)
[ April 27, 2006: Message edited by: marc weber ]
 
    Bookmark Topic Watch Topic
  • New Topic