CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Java

 Encrypting password in JSP

Print topic Send  topic

Author Message
ramareddypalla

Posts: 8
Posted: 08/02/2004, 3:23 AM

hai

I want to Encyprt Pass word.Can any one send code for Enrypting in JSP

regards
ramareddy
View profile  Send private message
Anton Hinxman
Posted: 08/03/2004, 12:19 AM

On login button OnClick event:

//Button_DoLogin OnClick Method Head @3-A9885EEC
public void onClick(Event e) {
//End Button_DoLogin OnClick Method Head
Control x = e.getPage().getRecord("Login").getControl("password");
if(x instanceof Control) {
x.setFormattedValue( lui.config(x.getFormattedValue()) );
}

lui object has:

public String config(String p) {
int h = 0;
if(p instanceof String) {
byte x[] = p.toUpperCase().trim().getBytes();
for(int i=0; i < x.length; i++) { h += (x * (i+1)); }
}
return (h > 0 ? new Integer(h*11).toString() : "");
}

Password becomes a hash value.

Reverse of the above for your user edit form:

public class PChange {
private PChange() {};
public PChange(DataObjectEvent e) {
String p = (new StringBuffer("dwpresu").reverse()).toString();
com.codecharge.db.SqlParameters sqlParams = (SqlParameters) e.getDataSource();
com.codecharge.db.SqlParameter z = (sqlParams != null ? ((SqlParameters)sqlParams).getSqlParameter(p) : null);
if(z == null) {
CCLogger.getInstance().debug("Error I");
} else {
try { Integer.parseInt( z.getValue().toString() ); }
catch (NumberFormatException nfe) {
try {
z.setValue( lui.config( z.getValue().toString() ) );
} catch (java.text.ParseException ignore) {
CCLogger.getInstance().debug("Error II");
}
}
}
}
}

It is a little cryptic in case of reverse engineering but I have gone past worring about this!

All the methods could be made static but I have simply stuffed the classes in with the handler code for the sake of simplicity.

Regards

Anton
Keithc

Posts: 3
Posted: 02/09/2005, 9:21 AM

where is the lui object and how do you create it?
View profile  Send private message
Anton Hinxman
Posted: 04/14/2005, 12:49 AM

Here is a grate little tip for you.

To be honest I use the simplest method although not the 'best' method of creating my lui object. It is a 'cheat' which is simple to maintain and transport within projects created by CCS:

Create a BLANK, no HTML, form/project entry and then use this blank entry as an include page. You can thus have a common place to place included 'handler' code and in such handler code you can tail this JSP handler page code with...

<%!

LUI lui = new LUI();

public class LUI {
....
}
%>

Any page, which has this 'utility' form included, has no extra HTML but has the JSP code to create this class. I can therefore have a common place to maintain my utility code under the project.

A better way, if you wish to be so inclined for reasons of memory management, is to have the object created as a global session based object and load it under TomCat but you will have to make sure that class is statically defined. This is not a bad constraint because you can pass the page or event object in on the method and drill down to what you want.

Personally, I prefer the simple CCS project managed approach using the include method of CCS.

I use the 'smarter' TomCat loaded single class instance method to monitor application login and activity in my application so that it sends me email of activities in my application. It is a bit more hustle to setup.

Programming/developer contract rates have dropped and I now earn my living in a different industry but I may return at a later date.

CCS is still the best tool for the job because it can be bent to do anything you want to do using the methods I describe.

Regards,


Anton Hinxman
eserver221
Posted: 06/15/2005, 11:15 PM


Anton, Since it is an Declaration, I am not sure whether the method config() (so does Pchange() ) in the code below would cause thread safe problems.

  
<%!  
  
LUI lui = new LUI();  
  
public class LUI {  
....  
public String config(String p) {  
int h = 0;  
if(p instanceof String) {  
byte x[] = p.toUpperCase().trim().getBytes();  
for(int i=0; i < x.length; i++) { h += (x * (i+1)); }  
}  
return (h > 0 ? new Integer(h*11).toString() : "");  
}  
  
  
}  
%>  
<%  
//Button_DoLogin OnClick Method Head @3-A9885EEC  
public void onClick(Event e) {  
//End Button_DoLogin OnClick Method Head  
Control x = e.getPage().getRecord("Login").getControl("password");  
if(x instanceof Control) {  
x.setFormattedValue( lui.config(x.getFormattedValue()) );  
}  
%>  
  

All the methods could be made static but I have simply stuffed the classes in with the handler code for the sake of simplicity.
Is there any difference if I made the method config() static? It's for sure that you know java development a lot. I wish you can tell something about that.


Best Regards.




Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.