jimmyjoe
asked on
Help with code...
I want to have the user enter encrypted text in a text box then click a button to view it unencrypted.
Assume
#1: user already has the encrypted text
#2 The text needs to be unencrypted by the following
Public String decode(String s)
{
byte byte0 = 20
s = s.trim();
int j = s.length();
char ac[] = s.toCharArray();
for(int i = 0; i < j; i++)
{
int k = ac[i] - byte0;
if(k < 32)
ac[i] = (char) (95 + k);
else
ac[i] = (char)k;
}
String s1 = new String(ac);
return s1;
}
Assume
#1: user already has the encrypted text
#2 The text needs to be unencrypted by the following
Public String decode(String s)
{
byte byte0 = 20
s = s.trim();
int j = s.length();
char ac[] = s.toCharArray();
for(int i = 0; i < j; i++)
{
int k = ac[i] - byte0;
if(k < 32)
ac[i] = (char) (95 + k);
else
ac[i] = (char)k;
}
String s1 = new String(ac);
return s1;
}
What exactly is your question? Do you want an example of this being done in a command line situation?
ASKER
I need the HTML to make it happen...
oh, so this is an applet, then, correct?
when you embedd the applet, give it a name
<APPLET name="myapplet"> or something
make sure your decode method is public, and
write a little script that calls it from the html side
<script language="javascript">
function decode(inputfield) {
var encodedstring=inputfield.v alue;
var decodedform=inputfield.for m["decoded "];
var decodedstring=document.mya pplet.deco de(encoded string)
decodedform.value=decodeds tring;
}
</script>
then you can have a text box like so
<form method="get" action="#">
<input type="text" name="encoded">
<input onclick="decode(this);" type="button" value="decode"><br />
Decoded: <input name="decoded" type="text"><br />
</form>
That's the rought idea, try it out.. hope it helps
I heard that there was a limiation on the IE MAC's jvm that doesn't allow scripting applets, you might want to make sure.
<APPLET name="myapplet"> or something
make sure your decode method is public, and
write a little script that calls it from the html side
<script language="javascript">
function decode(inputfield) {
var encodedstring=inputfield.v
var decodedform=inputfield.for
var decodedstring=document.mya
decodedform.value=decodeds
}
</script>
then you can have a text box like so
<form method="get" action="#">
<input type="text" name="encoded">
<input onclick="decode(this);" type="button" value="decode"><br />
Decoded: <input name="decoded" type="text"><br />
</form>
That's the rought idea, try it out.. hope it helps
I heard that there was a limiation on the IE MAC's jvm that doesn't allow scripting applets, you might want to make sure.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.