Showing posts with label password. Show all posts
Showing posts with label password. Show all posts

Saturday, February 18, 2017

VBScript Create Rar File With Password Protection Using WinRar.exe

VBScript is a scripting language to manage computer developed by Microsoft. Sometimes we need to create .rar file using WirRar.exe and use VBScript. Below is a code snippet to create rar file using both VBScript & WinRar.exe. There is a extension you can use password to protect your rar file. -p"PASSWORD" will create a rar file with password or if you use only -p as arguments then a prompt will appear to take password from user as input. -r use to create recursive all folders and files withing the root folder. -hs argument for include all hidden files.

Dim ObjShell, FSO
Set ObjShell = WScript.CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")

Wscript.StdOut.Write "Enter Source: "
Source = Wscript.StdIn.ReadLine

Wscript.StdOut.Write "Enter Destination: "
Destination = Wscript.StdIn.ReadLine

Wscript.StdOut.Write "Delete Source: "
DeleteSource = Wscript.StdIn.ReadLine

ObjShell.Run """C:\Program Files\WinRAR\WinRar.exe"" a -x -IBCK -ep1 -r -hs -p """ & Destination & """ """ & Source & """ ", 0, True
Set ObjShell = Nothing

Sub CheckRarCreated
    If (FSO.FileExists(Destination)) Then
       WScript.Echo Destination & " Created"
       If StrComp(DeleteSource, "True", 1) = 0 And FSO.FolderExists(Source) Then
          FSO.DeleteFolder Source
       End If
    Else
       WScript.Echo Destination & " Not Created"
    End If
End Sub
CheckRarCreated

Wednesday, November 9, 2016

Git clone with user name and password

1. Use: 
git clone https://user:password@server.org/username/repo.git

2. Or (It will prompt you for your password):
git clone https://user@server.org/username/repo.git

Tuesday, July 23, 2013

Password-Protect a Directory With .htaccess


Warning: On at least some versions of Ubuntu, .htaccess files will not work by default. See EnablingUseOfApacheHtaccessFiles for help on enabling them.
Create a file called .htaccess in the directory you want to password-protect with the follwing content:
 
AuthUserFile /your/path/.htpasswd
AuthName "Authorization Required"
AuthType Basic
require valid-user


instead of valid-user, you can also add the users you want directly
If you want to password protect just a single file in a folder add the following lines to the .htaccess file:
 
<Files "mypage.html">
  Require valid-user
</Files>


Then create the file /your/path/.htpasswd which contains the users that are allowed to login and their passwords. We do that with thehtpasswd command:
 
htpasswd -c /path/to/your/.htpasswd user1


The -c flag is used only when you are creating a new file. After the first time, you will omit the -c flag, when you are adding new users to an already-existing password file. Otherwise you will overwrite the file!!
Nevertheless, you should store the file in as secure a location as possible, with whatever minimum permissions on the file so that the web server itself can read the file.
Finally we need to add the following lines to /etc/apache2/apache2.conf:
 
<Directory /your/path>
AllowOverride All
</Directory>


You have to adjust /your/path/.htpasswd
Restart your webserver:
 
sudo /etc/init.d/apache2 restart

Troubleshooting


If you can't access your stuff and the dialog keeps popping up, check that you entered the username and password correctly. If it still doesn't work, check the path to your .htpasswd and make sure the path specified in the AuthUserFile directive is correct. Also make sure that both the.htpasswd and .htaccess files are readable by the web server user chmod 644 should do the trick!

Example


Here is an example on how to prevent users from access the directory, password-protect a specific file and allow userse to view a specific file:
AuthUserFile /your/path/.htpasswd
AuthName "Authorization Required"
AuthType Basic
Order Allow,Deny
<Files myfile1.html>
 Order Allow,Deny
 require valid-user
</Files>

<Files myfile2.html>
 Order Deny,Allow
</Files>

Redirect requests using .htaccess and mod_rewrite


  1. Make sure Apache .htaccess is enabled (by default it is enabled in Ubuntu)
  2. Make sure the Apache module mod_rewrite is enabled. Execute:
sudo a2enmod rewrite

..and see if rewrite is listed here:
sudo apache2ctl -M

and then you can redirect requests using RewriteRules. Example:
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?_REQUEST=$1 [L]

If you are running windows as your server, create a file .htpasswd at any location with the content.
pritom:pritom
ajay:ajay

Friday, April 19, 2013

Check password strength / safety with PHP and Regex

<?php
function checkPasswordLength($password, &$message) {
    if(strlen($password) < 8) {
        $message = "Password too short!";
        return false;
    }
    if(strlen($password) > 20) {
        $message = "Password too long!";
        return false;
    }
    if( !preg_match("#[0-9]+#", $password) ) {
        $message = "Password must include at least one number!";
        return false;
    }
    if( !preg_match("#[a-z]+#", $password) ) {
        $message = "Password must include at least one letter!";
        return false;
    }
    if( !preg_match("#[A-Z]+#", $password) ) {
        $message = "Password must include at least one CAPS!";
        return false;
    }
    if( !preg_match("#\W+#", $password) ) {
        $message = "Password must include at least one symbol!";
        return false;
    }
    return true;
}
?>