473,403 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Encrypting a javascript variable

hi,
I have entered a value in a text box , i have called a javascript function.
There i have written as under:
[ var old=document.frm.old.value;
old1=crypt([old,key]);
alert(old1); ]

I am not getting any error message in the javascript , neither i am getting the alert message.
if i remove the crypt function line and display alert message as alert(old),
then i am hetting the value of the textbox in that variable. So, i think there is something wrong in my crypt function. So, Could anyone tell me the correct syntax for a crypt function that works perfectly?

Thanks & Regards,
pavan .
Jun 20 '08 #1
3 4757
acoder
16,027 Expert Mod 8TB
Show your crypt function. Note that encrypting something using JavaScript for the purposes of hiding is not foolproof by any means and can be decrypted, sometimes quite easily.
Jun 20 '08 #2
hi ,
My entire javascript function is as under .
Expand|Select|Wrap|Line Numbers
  1.   function call(frm)
  2.        {
  3.                 var old=document.frm.old.value;
  4.                     old1=crypt([old,key]);
  5.                     alert(old1);
  6.                 var new1=document.frm.new1.value;
  7.                 var new2=document.frm.new2.value;
  8.  
  9.                 if(old=="" || new1=="" || new2=="")
  10.                 {
  11.             alert("Enter values");
  12.                         return;
  13.         }
  14.                 else 
  15.                 {
  16.               if(old!="$old_password")
  17.                       {
  18.                            alert("You have entered wrong old password!!! Try Again");
  19.                            return;
  20.                       }
  21.                       else
  22.                       {
  23.                 if(new1==new2)
  24.                             {   
  25.                  var url="http://10.202.1.24/shiftscheduler/master?session=$session_id&USERID=$UID&pass=1";
  26.                                  document.frm.action=url;
  27.                                  document.frm.submit();
  28.                 }
  29.                              else
  30.                              {
  31.                  alert("The two new passwords you have entered do not match!!! Enter again!!!");
  32.                                  return;
  33.                  }
  34.               }
  35.  
  36.                 }
  37.        }


In the above code $old_password is the already existing password in the database. $old_password is a perl variable. old_password is already encrypted in the database for security reasons. I have caught that encrypted value in the perl variable $old_password, but there is no decrypt function in perl.
So, i want to encrypt the javascript variable old. In the above code the javascript encrypt function crypt() is not working. So, please tell me a way to encrypt my javascript variable.

Thanks & Regards,
pavan
Jun 20 '08 #3
acoder
16,027 Expert Mod 8TB
You will have to use the same encryption algorithm used for encrypting the password in Perl. I suggest that you make this check in Perl rather than JavaScript. You can make an Ajax request if you want to avoid page reload.
Jun 20 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jason Davis | last post by:
Hi there, Is it possible to encrypt/protect a source code of Javascript to be run on WSCRIPT (not on a webpage)? Thanks! == Jas.
3
by: Piotr | last post by:
MS has published on its sites javascript encoder, which enables "encrypting" javascript code. It allows hiding js code from being seen as a text file. There is a decoder for it, available in the...
6
by: Dayne | last post by:
Guys, I am writing a database application(vb.net , sql server) and is presently storing the connection settings in a xml file...not very secure though. What is a safer method in a dynamic...
1
by: jimfortune | last post by:
This idea is still in the process of formulation. I'm considering the idea of storing encrypted data in memo fields. Since the data is for internal use only I don't think the legal limits on...
10
by: Onur Bozkurt | last post by:
I'am sending some data by the querystring. But I don't want it to be seen exactly because of security reasons. Is there a way to encrypt it and later decrypt when reading the querystring...? I...
2
by: SeeSharp Bint | last post by:
Visual Studio 2005, dotnet, c#. Microsoft SQL Server. Windows XP forms application. Temporarily, for my database application, I have been storing the various elements of database connection...
1
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.