Using SHA to encrypt password input on a form - sha

I know you like to see code, so here it is. All I want to do is to encrypt the password using SHA as it is entered. I have managed to encrypt the mysql database field to match it already.
I can't seem to find the correct syntax so I get a row of blobs instead of the password in clear text, which means it is not being sent to the server encrypted.
Thanks
<body>
<div id="container">
<div id="logo"><img src="images/Logo.jpg" alt="mycena" />
<div id="banner">
<h1>Shropshire Fungus Group</h1>
<p> </p>
</div>
</div>
<div id="ruler">
<hr />
</div>
</div>
<div class="menu"><ul class="nav" >
<li>Home</li>
<li>Membership</li>
<li>Resources</li>
<li>Gallery</li>
<li>Newsletters</li>
<li>Fixture List</li>
<li>Useful Links</li>
</ul>
</div>
<div id="intro">
<h2>Please complete your details to log in</h2>
<table>
<tr>
<td> Username: </td>
<td><input type="text" name="user" id="user" size="35" maxlength="50"/></td>
</tr>
<!-- password should be 8 characters or more in length -->
<tr>
<td> Password: </td>
<td><input type="text" name="upword" id="upword" size="40" maxlength="40"/></td>
</tr>
</table>
<p> </p>
<form action="loginphp170114.php" method="post" id="demo">
<input type="submit" value="Submit form" />
</form>

You'll need to use an external library such as this one, or else implement the sha1 algorithm yourself.
Note that sha1 is hashing, not encryption, and it's not a hash algorithm designed for storing passwords, so it's easily broken.

Related

How to sent an id outside the loop of handlebars to the form inside the handlebars?

<form method="POST" action="/admin/update-blog/{{blogs._id}}">
<div class="form-group">
<label for="exampleInputPassword1">HEADING</label>
<input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" value="{{blogs.heading}}" name="heading">
</div>
<br><br>
<div class="form-group">
<label for="exampleInputPassword1">BLOG</label>
<input type="text" class="form-control" id="exampleInputPassword1" value="{{blogs.blog}}" name="blog">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
<br><br>
<h2><i><b>Comments</b></i></h2>
<table class="table table-striped">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Email</th>
<th scope="col">Message</th>
</tr>
</thead>
<tbody>
{{#each blogs.comments}}
<tr>
<th scope="row"></th>
<td>
<form method="POST" action="/admin/delete-comment">
<div class="form-group">
<label for="exampleInputEmail1"></label>
<input type="email" class="form-control" id="myInput"readonly aria-describedby="emailHelp" placeholder="Enter email" value="{{this.email}}" name="email">
</div>
<button type="submit" class="btn btn-danger">delete</button>
</form>
</td>
<td>{{this.message}}</td>
</tr>
{{/each}}
</tbody>
</table>
How can i pass the {{blogs._id}} to a form which is inside a loop called {{#each blogs.comments}} .Is that possible.I am trying to delete a comment based on the email and the id of blog.Here the blog id is there in the top of code which is the first form where it displays the blog .And in the second form it displays the comments for the blog.
For me it is not possible to pass the id from blog to second loop(display comment).
I want to pass the id of blog to the action of the form in second loop(display comment)
THANKS IN ADVANCE😊
<option value="{{id}}">{{title}} {{../externalValue}}</option>
//The ../ path segment references the parent template scope that should be what you want.

How to get input field embedded in table using page-object accessor

Given the HTML snippet below how can I, using page-object field accessors, get the second input field, the one with id="333:".
I can't use the id to identify the field as it's auto-generated.
Using page-object accessors I can get the embedded table and the correct cell but the cell object is a PageObject::Elements::TableCell which doesn't seem to have any methods that allow access to the embedded span and input field.
I can get the input field using native Watir accessors - i.e., browser.div( ... etc ...) but would prefer to use just page-object accessors if possible.
If not possible then I'll live with native Watir. Thanks
<div class="modalContent">
<table role="presentation" id="324:_layoutTbl" class="axial">
<tbody>
<tr>
<td>
<input id="326:" name="" value="" onchange="juic.fire("326:","_change",event);" onfocus="juic.fire("326:","_focus",event);" onblur="juic.fire("326:","_blur",event);" type="text">
</td>
</tr>
<tr>
<td class="sfTH">
<label for="332:">Users:</label>
</td>
<td>
<table class="noborder" role="presentation">
<tbody>
<tr>
<th>
<label id="336:" class="rcmFormLabel">Hiring Manager</label>
<label id="337:" for="333:" class="rcmFormLabe">Users, Hiring Manager</label>
</th>
<td><span class="autocompspan ">
<input class="autocompinput" id="333:" name="333:" onfocus="juic.fire("333:","_focus",event);" size="20" value="Bill Murray" role="combobox" type="text">
<input value="111111" id="333:_hidden" name="333:_hidden" type="hidden">
</span>
<div id="335:" style="display:none"><img alt="" class="globalFloatLeft">
<div id="335:_error" style="color:#ff0000">undefined is required</div>
<div style="clear:both;"></div>
</div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
After more experimenting I found the answer to my question. I declared the table accessor, e.g., div(:my_table, :class => 'modalContent').table.table then in the code, to get the input field in the first row I did my_text_field = my_table_element[0].text_field_element which returned the PageObject::TextField object in column 2 of row 1

Apache Shiro keeps redirecting to login page

I am having some troubles with Apache Shiro when I put the right user and password in the login page. It keeps redirecting me to the same page every time.
Here I have my project structure.
Now my Shiro ini file content
[main]
# specify login page
authc.loginUrl = /admin/login.jsp
authc.successUrl = /admin/administracion.jsp
[users]
admin = admin
guest = 12345
[urls]
/admin/login.jsp = authc
/admin/** = authc
Now, the login html form
<form class="formulario" name="loginform" action="" method="POST">
<div id="descripcionPagina">
<h1>Login</h1><br>
Para ingresar al sistema <font color="red">identifíquese</font> como usuario del sistema.
<br>
</div>
<table id="tabla3" width="65%" cellpadding="8">
<tr id="fila">
<td align="right">
Identificación:
</td><td>
<input type="text" size="30"
id="Lusuario" name="user">
</td>
</tr><tr id="fila">
<td align="right">
Clave:
</td><td>
<input type="password" size="30"
id="Lpassword" name="password">
</td>
</tr><tr id="fila">
<td align="center" colspan="2">
<input type="submit" value="Ingresar">
</td>
</tr>
</table>
</form>
The web.xml is fine and doesn't contain any web session parameters. Any help would be very appreciated. Thank you.
I think that the problem is with the name of the fields:
Look at the source of the FormAuthenticationFilter (authc)
He need the fields : username and password.
You can change your html form
<input type="text" size="30" id="Lusuario" name="user">
to:
<input type="text" size="30" id="Lusuario" name="username">
Or you can add this in your shiro.ini
authc.usernameParam = user
I think /admin/logging.jsp should be anon instead of authc

How can I differentiate between two POST calls in expressjs?

I currently have two different forms on one inven.ejs file:
One for simple description:
///inven.ejs
<form method="POST" value="inven">
<div id="some-form" style="display: none;">
<table>
<tr>
<td><label for="item">Item</label></td>
<td><input type="text" name="item" required/></td>
</tr>
<tr>
<td><label for="text-box-value">Value</label></td>
</tr>
<tr>
<td><label for="comments">Comments</label></td>
<td><textarea rows="4" cols="50" required></textarea></td>
</tr>
<tr>
<td><input type="submit" /></td>
</tr>
</table>
</div>
</form>
and another for file upload:
///inven.ejs
<div id="fileUp">
<form id="fileUpload" name="fileUpload" enctype="multipart/form-data" method="post">
<fieldset>
<input type="file"id="fileSelect">
<input type="submit" name="upload" value="upload">
</fieldset>
</form>
</div>
In express, how can I differentiate between these two posts in my list.js file?
router.post('/list', function(req,res){
// ???
});
Do I need two routers? Am I completely doing this incorrectly?
Thank you!
EDIT:
Included an image, if it helps?
It makes sense to have forms post to a different address.
That is, <form id="fileUpload" action="file_upload" ... >
Then, if the form is found at http://server/my_form, it will post to http://server/file_upload
In your Node.js router you need to catch that and done.
If you still desire to send both forms to the same address, you can then use hidden fields.
Example: <input type="hidden" name="form_type" value="file_up_form">. Then in your Node.js you check for the argument form_type and check its value.

Session Management in Liferay

How come I customize the session in Liferay?Sample codes are welcome as it will help more,I am pretty new to Liferay?
To be more specific, i'll explain what i've done. Using Custom JSPs Hooks , i have overridden the $PORTAL_ROOT_HOME/html/portlet/login login.jsp and created my own jsp page and also overridden the LoginAction class.My login.jsp page looks like:
<aui:form action="" method="post">
<table>
<tr>
<td>Username :</td>
<td><input name="login" size=15 type="text" /></td>
</tr>
<tr>
<td>Password :</td>
<td><input name="password" size=15 type="password" /></td>
</tr>
</table>
<aui:button type="submit" value="sign-in"/>
</aui:form>
Now please tell upon clicking on the submit button , how can i get the login values in LoginAction.java and hence set the values to session. This is what i mean by customizing.
You should have copied the origonal login.jsp file from the start. By the looks of your codesnipsets you forgot to set the action to your loginAction. This can be done the following way:
<portlet:actionURL secure="<%= PropsValues.COMPANY_SECURITY_AUTH_REQUIRES_HTTPS || request.isSecure() %>" var="loginURL">
<portlet:param name="saveLastPath" value="0" />
<portlet:param name="struts_action" value="/login/login" />
<portlet:param name="doActionAfterLogin" value="<%= portletName.equals(PortletKeys.FAST_LOGIN) ? Boolean.TRUE.toString() : Boolean.FALSE.toString() %>" />
</portlet:actionURL>
<aui:form action="<%= loginURL %>" method="post">
<table>
<tr>
<td>Username :</td>
<td><aui:input name="login" size=15 type="text" /></td>
</tr>
<tr>
<td>Password :</td>
<td><aui:input name="password" size=15 type="password" /></td>
</tr>
</table>
<aui:button type="submit" value="sign-in"/>
</aui:form>
Please note that it is better to copy the orginal $PORTAL_ROOT_HOME/html/portlet/login/ login.jsp to your hook. Then make the modifications if any needed.
Your Hook will break / remove allot of existing functionality if the provided snipset is all you have.
To receive the parameters from the action you can use Pauls answer.
You can get login values with this code:
String login = ParamUtil.getString(request, "login");
String password = ParamUtil.getString(request, "password");
To set some values to session use this:
HttpSession session = request.getSession();
session.setAttribute("parm", "somevalue");
BR,
Paul

Resources