Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 2nd, 2008, 07:13 AM
Registered User
 
Join Date: Aug 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Base64Encoder and Md5 Incomplete Source code

Hi,

I'm trying to complete the following source code so that I can convert to c# to test if the token produced from both languages are exactly the same:

JAVA Snapshot source:

import java.lang.*;
import java.util.*;
import java.net.*;

import java.util.Scanner;
import java.io.*;
import java.security.*;

public class clstoken {
private String strToken;

public static void main(String[] args) {
    clstoken objtoken = new clstoken();
    objtoken.createToken("name a","name b","name c");
}

public void createToken (String str_A, String str_B, String str_C){
String strtime = Long.toString (System.currentTimeMillis ());
this.strToken = URLEncoder.encode (str_A, "UTF-8")
     + ":"
     + URLEncoder.encode(str_B, “UTF-8”)
     + ":"
     + strtime
     + ":"
     + new Base64Encoder ().encode (
    new Md5 (str_A + str_B + strtime + str_C).getDigest ());
System.out.println("Token is " + this.strToken);

}
}


If I run this 'Base64Encoder' and 'Md5' classes cannot be found. I'm not too sure if JAVA 1.6 contains these classes as I cannot find them. Can anyone help complete the source?

I'm running Windows XP Pro and JAVA 1.6.

Thanks,
P
 
Old April 7th, 2008, 03:54 AM
jomet
Guest
 
Posts: n/a
Default

There is no Base64 encoder/decoder in the standard Java SDK class library

check
http://www.wikihow.com/Encode-a-Stri...se64-With-Java

jomet.
---------------------------------------------
Once you start a working on something,
dont be afraid of failure and dont abandon it.
People who work sincerely are the happiest.
 
Old April 8th, 2008, 05:48 AM
Registered User
 
Join Date: Aug 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks jomet, managed to complete the source and convert to c#.

Nice one!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Shopping Cart Code incomplete dipeshedesign BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 3 September 23rd, 2009 12:06 PM
md5 code !!!!! angelboy C# 2005 1 March 7th, 2007 03:25 AM
Md5 encryption rahuljain_w .NET Web Services 2 September 30th, 2005 05:03 AM
Need BASE64Encoder, BASE64Decoder JAR or Classes inderjeet_79 Java Databases 0 March 11th, 2005 12:16 PM
Incomplete code base razneesh BOOK: Expert One-on-One J2EE Design and Development 0 July 19th, 2004 08:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.