What would be the Windows batch equivalent for HTML’s input type=”password”?

check out this http://www.netikka.net/tsneti/info/tscmd052.htm @echo off & setlocal enableextensions :: Build a Visual Basic Script set vbs_=%temp%\tmp$$$.vbs set skip= findstr “‘%skip%VBS” “%~f0” > “%vbs_%” :: :: Prompting without linefeed as in Item #15 echo.|set /p=”Password: ” :: Run the script with Microsoft Windows Script Host Version 5.6 for /f “tokens=* delims=” %%a in (‘cscript //nologo … Read more

Opening password-protected pdf file with iTextSharp

For certain operations on encrypted documents iText(Sharp) requires that the document not merely is opened with the user password but instead with the owner password. This corresponds to the definition of these passwords in the PDF specification: Whether additional operations shall be allowed on a decrypted document depends on which password (if any) was supplied … Read more

str_shuffle and randomness

A better solution would be mt_rand which uses Mersenne Twister which much more better. As has been pointed out, the str_shuffle method is not equivalent to the code I’m already using and will be less random due to the string’s characters remaining the same as the input, only with their order changed. However I’m still … Read more

Regex for checking that at least 3 of 4 different character groups exist

Just to learn – would this kind of requirement be possible to implement in pure regex? That’d make it a rather hard to read (and therefor maintain!) solution, but here it is: (?mx) ^ ( (?=.*[a-z])(?=.*[A-Z])(?=.*[0-9]) # must contain a-z, A-Z and 0-9 | # OR (?=.*[a-z])(?=.*[A-Z])(?=.*[!@\#$%&/=?_.,:;\\-]) # must contain a-z, A-Z and special | … Read more

How can I make an expect script prompt for a password?

Use expect’s stty command like this: # grab the password stty -echo send_user — “Password for $user@$host: ” expect_user -re “(.*)\n” send_user “\n” stty echo set pass $expect_out(1,string) #… later send — “$pass\r” Note that it’s important to call stty -echo before calling send_user — I’m not sure exactly why: I think it’s a timing … Read more

How to store passwords in Winforms application?

The sanctified method is to use CryptoAPI and the Data Protection APIs. To encrypt, use something like this (C++): DATA_BLOB blobIn, blobOut; blobIn.pbData=(BYTE*)data; blobIn.cbData=wcslen(data)*sizeof(WCHAR); CryptProtectData(&blobIn, description, NULL, NULL, NULL, CRYPTPROTECT_LOCAL_MACHINE | CRYPTPROTECT_UI_FORBIDDEN, &blobOut); _encrypted=blobOut.pbData; _length=blobOut.cbData; Decryption is the opposite: DATA_BLOB blobIn, blobOut; blobIn.pbData=const_cast<BYTE*>(data); blobIn.cbData=length; CryptUnprotectData(&blobIn, NULL, NULL, NULL, NULL, CRYPTPROTECT_UI_FORBIDDEN, &blobOut); std::wstring _decrypted; _decrypted.assign((LPCWSTR)blobOut.pbData,(LPCWSTR)blobOut.pbData+blobOut.cbData/sizeof(WCHAR)); If … Read more

Regex for password PHP [duplicate]

^\S*(?=\S{8,})(?=\S*[a-z])(?=\S*[A-Z])(?=\S*[\d])\S*$ From the fine folks over at Zorched. ^: anchored to beginning of string \S*: any set of characters (?=\S{8,}): of at least length 8 (?=\S*[a-z]): containing at least one lowercase letter (?=\S*[A-Z]): and at least one uppercase letter (?=\S*[\d]): and at least one number $: anchored to the end of the string To include … Read more