Simple Basic Encryption – Most commonly used algorithms

Problem

Want to know the encryption short or long names.



Solution

DES – Digital Encryption Standard. Symmetric block encryption algorithm

3DES – Triple DES. Symmetric block algo – uses DES three times.

RC4 – Rivest Cipher #4. Symmetric algo uses stream encryption.

RSA – Rivest, Shamir, Adelman. Symmetric block algo.

IDEA – International Data Encryption Algo, symmetric block algo – used by PGP.

AES – Advanced Encryption Standard (Rijndael) – symmetric block algo.



Example


Demo of des3, rc4 and aes256 – using abc123 as password and thecatsatonthemat

$ echo thecatsatonthemat |  openssl enc -des3 -a -e -k abc123U2FsdGVkX1/I03dG1d8bGYycfojc4x/S5uU1YIf1QRPRw+9AgKhVCw==$ echo "U2FsdGVkX1/I03dG1d8bGYycfojc4x/S5uU1YIf1QRPRw+9AgKhVCw==" | openssl enc -des3 -a -d -k abc123thecatsatonthemat$ echo thecatsatonthemat |  openssl enc -rc4 -a -e -k abc123U2FsdGVkX1+NuZk94r5kJdFfw8gsjlO9ZV7BDXLwm+3PNg==$ echo "U2FsdGVkX1+NuZk94r5kJdFfw8gsjlO9ZV7BDXLwm+3PNg==" |  openssl enc -rc4 -a -d -k abc123thecatsatonthemat$ echo thecatsatonthemat |  openssl enc -aes256 -a -e -k abc123U2FsdGVkX1/bGQ0rtpGi6CjkeAyyEgQjnxkSWBQ6q7XLgAApdWHA5BdEuK24r/NY$ echo "U2FsdGVkX1/bGQ0rtpGi6CjkeAyyEgQjnxkSWBQ6q7XLgAApdWHA5BdEuK24r/NY" |  openssl enc -aes256 -a -d -k abc123thecatsatonthemat


Reference

Wiki links



Creating favicon.ico

Problem

You want to create a favicon.ico from Unix.



Solution

  1. Open your image with GIMP
  2. If your image is not a square then resize the canvas with GIMP
  3. Scale the image to 16×16 pixel (Image, Scale image)
  4. Save as favicon.pnm or favicon.ppm with raw encoding
  5. Close GIMP


Example


Then to convert favicon.pnm or favicon.ppm using the command line utility ppmtowinicon:

$ ppmtowinicon -output favicon.ico favicon.pnm

Or

$ ppmtowinicon -output favicon.ico favicon.ppm


Reference

Kewl tip on creating a favicon.ico with ppmtowinico – thanks to linuxproblem.org. 🙂

http://www.linuxproblem.org/art_19.html



Blogging Tip – do your quotes turned to dots when pasting

Problem

One annoying thing I recently discovered, when copying code from my blogs (yes I use my own tips too! 🙂 ), quotes seem to turn into dots. Both for single and double quotes.



Solution

The answer to this was explained in a blogging book, that apparently the quotes on a keyboard refer to feet and inches – not speech! 😉

The solution is simply to use ASCII notation.



Example


Therefore a double quote becomes " and a single '



Reference



Simple Basic MySql – beginning mysql mysqlshow

Problem

You want to perform command line display of mysql dbs with mysqlshow.



Solution

Is this demo, I show the options for mysqlshow.

mysqlshow is a real easy way to quickly view your dbs, tables and rows.



Example


Show Databases

$ mysqlshow -i -u'root' -p'xxxxxx'+---------------+|   Databases   |+---------------+| demo          || mysql         || test          |+---------------+

Show number of tables under each db

$ mysqlshow -v -i -u'root' -p'xxxxx'+---------------+--------+|   Databases   | Tables |+---------------+--------+| demo          |      1 || mysql         |     15 || test          |      0 |+---------------+--------+5 rows in set.

Show total number of rows for each db

[[email protected] ~]$ mysqlshow -v -v -i -u'root' -p'xxxxx'+---------------+--------+--------------+|   Databases   | Tables |  Total Rows  |+---------------+--------+--------------+| demo          |      1 |            7 || mysql         |     15 |         1383 || test          |      0 |            0 |+---------------+--------+--------------+5 rows in set.


Reference



Simple Basic MySql – beginning mysql db management

Problem

You want to know how to do the following, through mysql command line interface:

    Connect to the mysql daemon
    Show the databases your user has access
    Show tables defined under that db
    Show schema for given table


Solution



Example


mysql -u'username' -p'password' -h'mysql_host'

mysql_host is optional if the daemon is running on the same host.

Show databases

show databases;

Show tables

show tables;

Describe tables

use demo;describe demo;

For example:

mysql> show databases;+----------+| Database |+----------+| demo     || test     |+----------+2 rows in set (0.00 sec)mysql> use demo;Database changedmysql> show tables;+----------------+| Tables_in_demo |+----------------+| demo_table     |+----------------+1 row in set (0.00 sec)mysql> desc demo_table;+-------+--------------+------+-----+---------+-------+| Field | Type         | Null | Key | Default | Extra |+-------+--------------+------+-----+---------+-------+| id    | mediumint(9) |      | PRI | 0       |       || day   | varchar(20)  |      |     |         |       || val   | tinyint(4)   |      |     | 0       |       |+-------+--------------+------+-----+---------+-------+3 rows in set (0.10 sec)


Reference



Simple Basic Java Software – analysing arguments from command line

Problem

You want a simple bit of java code that takes arguments from the command line and displays them.



Solution

Good demo on how to obtain and handle java arguments.

public class Arguments {  public static void main(String argv[]) {    if(argv.length > 0) {      System.out.println("args exec w " + argv.length + " args");        for(int i=0;i...


Example


Here is a demo:

# java Arguments -a -x -yargs exec w 3 argsargv[0] = -aargv[1] = -xargv[2] = -y


Reference



First steps in vb scripting for windows / DOS

Problem

Starting out with a new series of tips, getting started with vb scripting. Microsoft have an excellent guide on the site, which I’ve link at the bottom of this post.



Solution

Below is the typical ‘hello world’ script



Example


C:\Documents and Settings\Admin > copy con test.vbsWscript.echo "Hello World."^Z1 file(s) copied.C:\Documents and Settings\Admin > cscript test.vbsMicrosoft (R) Windows Script Host Version 5.6Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.Hello World.




Switch to a different user in MS Windows / DOS

Problem

You want to switch user from the MS DOS prompt.



Solution

Use runas

runas /?


Example


Switch user to other id (Then just run explorer and browse to directory)

runas /user:[email protected] c:\winnt\system32\cmd.exe

Where user-id is the USER you wish to change to. For example Admin. xxx represents the hostname of the box or domain.

You can also just use local, if changing to user on the same box, like this:

C\:Documents and Settings\Admin runas /user:localmarcus "c:\WINDOWS\system32\cmd.exe"Enter the password for localmarcus:Attempting to start c\:WINDOWS\system32\cmd.exe as user "localmarcus" ...


Reference



Setting file permissions from command line in windows

Problem

You want to modify permissions in Windows from the DOS prompt command line.



Solution

Use cacls

cacls /?


Example


Here are the commands to modify MS Windows/DOS files and directories.

  • Display file permissions. Replace filename with your file name.
> cacls filename...filename            NT AUTHORITYSYSTEM:FPCxxxxxxxxxxxxAdmin:F
  • Modify permissions. Here we are granting full access to the user, replace user with desired user name.
> cacls filename /E /G user:Fprocessed file: C:...filename
  • Here we see the permissions have been reset:
> cacls filename...filename           PCxxxxxxxxxuser:FNT AUTHORITYSYSTEM:FPCxxxxxxxxxxxxxAdmin:F


Reference



Useful PHP tool to create an image with superimposed text

Problem

You want to create an image text label.



Solution

Use GD library that can be built-in to PHP. Or just use my free on-line tool to create it, as shown in example below.

Once GD is built in – use this PHP code to generate the label.



Example


This shows the label .

You can use this to generate black blank images, with white superimposed text over the top:

generate black blank images, with white superimposed text .. click this link, change text "label" – then save to your machine.



Reference