JavaScript - Rsa Encryption Function Is Not Working
I've been working on RSA encryption using javascript and php for quite some time but i'm not able to do it properly. i'm using the standard RSA.js,BigInt.js and Barrett.js javascript files for the javascript part but the thing that i have noticed is the public exponent is always 10001 or 3 . only then the function works. but the problem is the php file generates a comparatively larger public key exponent. if i use that in the javascript function it crashes. is there anyway out of this ?
Similar TutorialsI found this script, and it works great: Code: <script type="text/javascript"> function disable(element) { var input = document.getElementById(element).getElementsByTagName("input"); for(var i = 0; i < input.length; i++) { input[i].setAttribute("disabled","true"); } } </script> I tried to make the inverse by simply reversing the setAttribute() like so: Code: <script type="text/javascript"> function enable(element) { var input = document.getElementById(element).getElementsByTagName("input"); for(var i = 0; i < input.length; i++) { input[i].setAttribute("disabled","false"); } } </script> But that didn't do it. Can someone show me why, and how to fix it? Here's the sample form which I'm trying to test it on: Code: <form> <input type="radio" name="test" onclick="disable('D1')" /> disable<br/> <input type="radio" name="test" onclick="enable('D1')" /> enable<br/> <fieldset id="D1"> <input class="" type="text" value="test value1" /><input class="" type="text" value="test value2" /><br/> <input class="" type="text" value="test value3" /><input class="" type="text" value="test value4" /><br/> <input class="" type="text" value="test value5" /><input class="" type="text" value="test value6" /><br/> </fieldset> </form> Edit: The ultimate goal which I'm working toward now (step by step =) is to have a form more like: Code: <form> <input type="radio" name="test" onclick="disable('D1')" /> <fieldset id="D1"> <input class="" type="text" value="test value1" /><input class="" type="text" value="test value2" /> </fieldset> <input type="radio" name="test" onclick="disable('D2')" /> <fieldset id="D2"> <input class="" type="text" value="test value3" /><input class="" type="text" value="test value4" /> </fieldset> <input type="radio" name="test" onclick="disable('D3')" /> <fieldset id="D3"> <input class="" type="text" value="test value5" /><input class="" type="text" value="test value6" /> </fieldset> </form> And have the fieldsets enable and disable according the selection of the radio buttons. Also, the fieldsets (and their ID's) will be dynamically generated via PHP Thanks-a-bunch, ~ Mo I was going around few websites and found this: abitofextra dot com their source encryption is different and i have never really seen one like this. any ideas how they encrypted the source?! i work as freelancer and would be a great help if i could encrypt my codes too. I am having trouble getting my function to work here is what I have so far Code: <script type="text/javascript"> // script element to add the votes.js function totalVotes(votes1){ // script element that will calculate the array ****var total = 0; ****for (var i = 0; i < votes1.length; i++) { *******total = total + votes1[i]; ****} ****return total; } </script> Can anyone see whats wrong? when i run it i still get nothing Hello, I am new to this forum stuff so please bear with me. This is the code I am using. Code: <script type="text/javascript"> function ReadForm(obj1) { "use strict"; var amt = obj1.amount.value; obj1.amount.value = amt - (amt / 6.6); } </script> The value (obj1) is 99 It is supposed to return a value of 84 and I keep getting 99 DId I do something wrong ? Hi, What I did is not working. Using coldfusion. Have cfselect object (id="Decision") with 3 values - Select; Approved; Denied. Have two input buttons, Request Approved (id="approved") and Request Denied (id="denied"). The Approved is visible but disabled. The Denied is not visible. The user needs to select from "Decision" either Approved or Denied before he/she can submit. So when user selects Approved from drop-down I want to enable Request Approved submit button. If user selects Denied from drop-down I want the disabled Request Approved button to not be visible and the Request Denied button to be visible and enabled for submission. The respective buttons will be directed to their appropriate actions. Code: <script type="text/javascript"> var decide = function() { var choice = document.getElementById("Decision"); var apprvd = document.getElementById("approved"); var deny = document.getElementById("denied"); if (choice.value == "Approved") { deny.style.disabled = "disabled"; deny.style.visibility = "hidden"; apprvd.style.disabled = false; apprvd.style.visibility = "visible"; } if (choice.value == "Denied") { apprvd.style.disabled = "disabled"; apprvd.style.visibility = "hidden"; deny.style.disabled = false; deny.style.visibility = "visible"; } } </script> Nothing happens - any suggestions why not? Thanks - John OK so I am trying to put the following output together 2: 2 3: 3 4: 2,4 5: 5 6: 2,3,6 7: 7 8: 2,4,8 9: 3,9 10: 2,5,10 So I am looking for factors of numbers. User inputs a minimum and maximum and the function runs until it hits the max number. In between it is going to write out all of the factors for each line number. Here is function so far and it is NOT working function allFactors(num1,num2,outputDiv){ var min = parseInt(document.getElementById(num1).value); var max = parseInt(document.getElementById(num2).value); var output = ""; var start = 2; for (var i = 1; i <= max; ++i) { output += i+":" if (min/start == Math.round(min/start)){ output += start } else { ++start } }"<br />" addToDiv(outputDiv, output); } can i write the encryption type in javascript?? i am writing like this in my javascript function, but not able to getting it work...... document.form_name.enctype ="multipart/form-data" Hello, I want to use this script I got from he http://javascript.about.com/library/blencrypt.htm The examples there work fine for me. But what I cannot seem to do is use any other 'key' than one made by Code: hexToByteArray(genkey()); I've tried all the things I can think of, like Code: var key = stringToByteArray("mickeymouse"); for instance, doesn't work... The ciphertext just says 'undefined' when I try to display it. I really cannot see the problem here. I just want to be able to use a user supplied key, not a bloomin random one every time. This is really frustrating me, it's even invading my dream time! Does anyone know what's going wrong here? Please help. I am creating a weather widget for the iphone. The program creates an xml request for a weather feed and then parses the response. Depending on the response different information is displayed. A different icon for each weather pattern. I have all of this working so far. What I want to integrate is the option to refresh the weather when a user taps on the icon. Here is my code: Code: document.getElementByID("weatherIcon").innerHTML="<img src=\"Icon Sets/"+iconSet+"/"+MiniIcons[obj.icon]+iconExt/" border=2 onclick=\"refresh();\">" Code: function refresh() { weatherRefresherTemp(); } I know that the function refresh works because it is called from another function that allows the refresh to happen automatically every 30 min. However, wanting to integrate an option to manually refresh I am trying to do it this way. The code never seems to fire, nothing happens. I've added the border option for testing and don't even see that. I've been using a javascript editor and I do not get any errors. Any suggestions would be greatly apprectiated. I am trying to pass a value to another function, seems to work with the other function i have but not this one? any reasons why this wont work? Code: /* ---------------------------- */ /* XMLHTTPRequest Enable */ /* ---------------------------- */ function createObject() { var request_type; var browser = navigator.appName; if(browser == "Microsoft Internet Explorer"){ request_type = new ActiveXObject("Microsoft.XMLHTTP"); }else{ request_type = new XMLHttpRequest(); } return request_type; } var http = createObject(); /* -------------------------- */ /* SEARCH */ /* -------------------------- */ function autosuggest(q,f,r) { alert(q+' '+f+' '+r); // q = document.getElementById(var f).value; // // Set te random number to add to URL request nocache = Math.random(); http.open('get', 'ajax_search_for_airport.php?q='+q+'&f'+f+'&r'+r+'&nocache = '+nocache); http.onreadystatechange = autosuggestReply(r); /* this line is not working as expected, it kicks up an error Message: Type mismatch Line: 26 Char: 1 Code: 0 i am wanting to pas the value of r to the other function. */ http.send(null); } function autosuggestReply(r) { if(http.readyState == 4){ var response = http.responseText; e = document.getElementById(r); if(response!=""){ e.innerHTML=response; e.style.display="block"; } else { e.style.display="none"; } } } function fill(r,fieldid,resultsid) { e = document.getElementById(fieldid); e.value=r; document.getElementById(resultsid).style.display="none"; } hello, i have a form validator that works fine in chrome, safari, firefox...but not IE 8.. i'm pretty new at javascript... any help is appreciated Code: function detect() { if(navigator.cookieEnabled == false) { alert('You must enable cookies in your browser!'); return false; } if(document.add.color.value == "-Select Color-") { alert('Please select a color!'); return false; } if(IsNumeric(document.add.quantity.value) != true) { alert('This must be a number!'); return false; } if(document.add.quantity.value == 0) { alert('You must add at least one item!'); return false; } } and the html Code: <form name='add' onSubmit='return detect();' method='POST' action='process.php'> I'm having a small issue with being able to use the onclick more than once. When I load the page and click the link the request works fine the first time. But if I cancel the request then goto click the link again, nothing happens. Code: <a href="javascript:void();" onclick="sendRequest()">Send the request</a> <script> var request = { method: 'postrequest', message: 'You will like it', data: '123key' }; function sendRequest() { postReq(request, function (a) { if (a && a.post_id) { //Do something if sent } else { //Do something if cancelled } }) } </script> I've been stuck on a piece of code for awhile. I have two items but they won't run at the same time only one will work: Code: function loadProductK ( prSrc, imgSrc, prDesc, pr$, prStock, prAnchor, rank ) { var product ='<div class="productDiv" id="'+prAnchor+'"><img src="'+imgSrc+'" width="150" height="150" title="'+prDesc+'"/><div class="productname">'+prDesc+'</div><div class="product$">€'+pr$+'</div><div class="productstock">'+prStock+'<div class="productvisit"><li onclick="loadPage("'+prSrc+'")">Check product >></li></div></div>' var productpage = document.getElementById("imgLoad") productpage.innerHTML=product loadProductK ('page/p/bead1.html','page/i/bead1.jpg','Round Bead','1,22','In Stock','Bead1','1' ) loadProductK ('page/p/Bead2.html','page/i/Bead2.jpg','Three Round Beads','6,99','In stock','Bead2','2' ) } Now i need the function loadProductK to work for both of the loadProductK's as seen below. Really need some help on this one. Hi This is for a class project, for some reason only the first part is working. The (sales*.20) and all of my else if are not. Kind of stuck on this. Code: <script type="text/javascript"> function bonus() { var sales var excellent var good var fair var poor sales= document.workBonus.txtSales.value; sales= parseInt(sales); excellent= document.workBonus.chkExc.value; good= document.workBonus.chkGood.value; fair= document.workBonus.chkFair.value; poor= document.workBonus.chkPoor.vaule; if (sales && excellent) { alert(sales * .20) } else if (sales && good) { alert(sales * .10) } else if (sales && fair) { alert(sales * .05) } else if (sales && poor) { alert(sales * .01) } } </script> I'm presently trying to work through a tutorial at http://www.devarticles.com/c/a/JavaS...ld-Examples/3/ The code, as written in the tutorial fails when it comes to: Code: obj.onchange = function() { this.hideError(obj); }; Using Firefox's Web Developer Toolbar, I learned that (allegedly) "this.hideError(obj) isn't a function." Event though it is clearly presented in the code as a function: Code: // define 'hideError()' method this.hideError = function(obj) { obj.parentNode.removeChild(obj.errorNode); obj.errorNode =null; obj.onchange =null; this.valid =true; }; If I replace the obj.onchange with the contents of the function: Code: obj.onchange = function() { //this.hideError(obj); obj.parentNode.removeChild(obj.errorNode); obj.errorNode =null; obj.onchange =null; this.valid =true; }; this now works... almost: it works when I hit the submit button. This begs two questions: 1. What is wrong with the this.hideError(obj); function that none of my browsers (e.g. IE, FireFox, Chrome) recognize it as such? 2. Why are these browsers waiting for me to hit submit again, rather than changing as I change the contents of the input element? How could I fix this? I have a need of a Java Script function to encrypt passwords into Salted SHA in a format similar to the way LDAP stores it. Does anyone know if this has ever been done? I read that you don't allow homework assignments to be posted, but this is only one small section of the assignment (1 page of 5), and I have a migraine, and I am utterly hopeless and lost (ha)... I was wondering if there was any errors you could point out to me that would explain why the button isn't doing ANYTHING (i.e. not calculating the sum, average, or grade) when i click it. I'm new to js so I'm sure it could be pretty much any n00b error in the function code. But like I said any help would be greatly appreciated... Code: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <link href="5A.css" rel="stylesheet" type="text/css" media="screen"/> <script type="text/javascript"> function DisplayGrades() { var aNum= 1* document.getElementById("txtaNum").value; var bNum= 1* document.getElementById("txtbNum").value; var Avg = (aNum+bNum)/2; document.getElementById("txtAvg").value=Avg; var Sum= aNum+bNum; document.getElementById("txtSum").value=Sum; var alphaGr= document.getElementbyID("txtalphaGr").value=alphaGr; if (Avg <= 60) alphaGr="F"; if (Avg>60 && Avg <= 70) alphaGr="D"; if (Avg>70 && Avg <= 80) alphaGr="C"; if (Avg>80 && Avg <=90) alphaGr="B"; if (Avg>90 && Avg <=100) alphaGr="A";} </script> </head> <body> <div id="wrapper"> <div id="interact"> Enter your grade for Test 1: <input type="text" id=txtaNum" class="controls" size="10" /> <br /> Enter your grade for Test 2: <input type="text" id=txtbNum" class="controls" size="10" /> <br /> <input type="button" id="btnDisplayGrades" value="Display Grades" onclick="DisplayGrades();" /> <hr/> Sum of Your Grades: <input type="text" id="txtSum" class="controls" size="10" readonly="readonly" /> <br/> Average Grade: <input type="text" id="textAvg" class="controls" size="10" readonly="readonly" /> <br /> Alpha Grade: <input type="text" id="txtalphaGr" class="controls" size="10" readonly="readonly" /> </div> </div> </body> </html> I have the following Javascript function that just refuses to work in Internet Explorer (since IE is absolute .......). Can anybody tell me why this wouldn't be working in IE and what I need to do to fix it? I am new to Javascript so don't really have any idea Code: function displaymember() { var d = new Date(); var curr_date = d.getDate(); if (curr_date < 10) curr_date = "0" + curr_date; var curr_month = d.getMonth(); curr_month++; if (curr_month < 10) curr_month = "0" + curr_month; var curr_year = d.getFullYear(); //alert("date="+curr_date+" month="+curr_month+" year="+curr_year); for (i = 0; i < x.length; i++) { membershipstatus = (x[i].getElementsByTagName("membership_status")[0].childNodes[0].nodeValue); name = (x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue); body = (x[i].getElementsByTagName("body_type")[0].childNodes[0].nodeValue); ethnicity = (x[i].getElementsByTagName("ethnicity")[0].childNodes[0].nodeValue); sex = (x[i].getElementsByTagName("sex")[0].childNodes[0].nodeValue); profession = (x[i].getElementsByTagName("profession")[0].childNodes[0].nodeValue); seeking = (x[i].getElementsByTagName("seeking")[0].childNodes[0].nodeValue); date = (x[i].getElementsByTagName("date_joined")[0]); month = (date.getElementsByTagName("month")[0].childNodes[0].nodeValue); year = (date.getElementsByTagName("year")[0].childNodes[0].nodeValue); newa = document.createElement('a'); aIdName = 'my' + i + 'a'; ahref = '#'; aclick = 'show(' + i + ')'; newa.setAttribute('id', aIdName); newa.setAttribute('href', ahref); newa.setAttribute('onclick', aclick); newa.innerHTML = name + " | " + body + " " + ethnicity + " " + sex + " " + profession + " with " + membershipstatus + " membership seeks " + seeking + "<br/>"; if (curr_month == month && curr_year == year) { document.getElementById("member").appendChild(newa); } } } Hi guys, I am having a problem where the sorting function I have designed is supposed to sort an array of records into descending order in terms of each record's "score" value, I would expect the below code to alert 2,1,0 in that order but it's as if the code didn't even sort it. Help would greatly be appreciated Code: var g=[{sco 0,index:0},{sco 2,index:1},{sco 1,index:2}] function sortScores(scoreRecs){ var swapped; do for(i=0;i<scoreRecs.length-1;i++){ if(scoreRecs[i].score<scoreRecs[i+1].score){ var a=scoreRecs[i] var b=scoreRecs[i+1] var c=a; a=b; b=c; swapped=true; } else{ swapped=false; } } while(swapped==true) } sortScores(g); alert(g[0].score); alert(g[1].score); alert(g[2].score); |