Monthly Archives: April 2013

Generate password with bash

You can use the following shell function to generate random password.

Edit ~/.bashrc file, enter:

Save and close the file. Source ~/.bashrc again, enter:

To generate random password, enter:

To generate 8 character long random password, enter:

Share

Enable proxy for apt-get on Ubuntu

When you are behind a proxy server on your ubuntu machine you have to edit (or create) your apt.conf to define the proxy settings:

Create (or edit) an apt.conf  file at  /etc/apt/apt.conf
Add the following line to this file:

Acquire::http::Proxy "http://username:password@proxyhost:port/";

If you have any special characters in your password you have to use the URL encoding syntax. For example a ! translates to %21.

The next time you use apt-get the proxy settings will be used.

Share

Visual Studio Tips & Tricks

Visual Studio tips and tricks.

Visual Studio
This article contains tips and tricks about Visual Studio. Tips are collected during day to day work with Visual Studio.

Searching with regular expression

Type Ctrl-F, in Find Options select Regular expression instead of “Wild card”
Type your regular expression; for example [.]isual studi[.]
The default behavior is greedy matching; to use non-greedy matching use the @ (instead of *) or
the # (instead of .)

Keyboard short-cuts

Show command window Ctrl-Alt-A
Cycle through clipboard buffer Ctrl-Shift-V
Toggle display whitespace Ctrl-R, Ctrl-W
Show options for smart-tag Ctrl-.

Various tips and tricks

To start a shell from visual studio open the command window (Crl-W,A). Type “Tools.Shell cmd”.

Share

Cryptography notes, tips and tricks

Cryptography notes.

This article is about cryptography and asymmetric encryption / decyption.
Asymmetric (public / private key pair) and symmetric (one key to encrypt and decrypt).

– distribute your public key
– keep your private key secret and private 🙂

Ask people who want to send you a secret mail to encrypt it with the public key. Only you, the owner of the private key, are able to decrypt it.

Install openSSH from http://slproweb.com/products/Win32OpenSSL.html (Visual C++ 2008 Redistributables and Win32 OpenSSL v1.0.1c).

Add the installation folder to your path and adjust the environment variable OPENSSL_CONF to point to your configuration file.

Asymmetric encryption of a file:
1. Create a private key and public key pair:
> openssl genrsa -out private.pem 1024
1a. Encrypt you private key:
> openssl rsa -in private.pem -des3 -out private-enc-key.pem
2. Extract the public key from this file (the public.pem, created below, can be freely distributed):
> openssl rsa -in private.pem -out public.pem -outform PEM -pubout
3. Encrypt a file:
> openssl rsautl -encrypt -inkey public.pem -pubin -in file.txt -out file_enc.txt
4. Decrypt the file with your private key:
> openssl rsautl -decrypt -inkey private.pem -in file_enc.txt -out decrypted.txt

Retrieve information about your private key (generated with genrsa command):
> openssl rsa -in privateKey.pem -text

NOTES

Privacy Enhanced Email (PEM)

http://users.dcc.uchile.cl/~pcamacho/tutorial/crypto/openssl/openssl_intro.html

 

Share