Simple Basic Encryption – Most commonly used algorithms

[problem]

Want to know the encryption short or long names.

[/problem]

[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.

[/solution]

[example]

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

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

[/example]

[reference]

Wiki links

[/reference]

[tags]Encryption, DES, 3DES, RC4, RSA, IDEA, AES[/tags]

Creating favicon.ico

[problem]

You want to create a favicon.ico from Unix.

[/problem]

[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

[/solution]

[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 

[/example]

[reference]

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

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

[/reference]

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.

[/problem]

[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.

[/solution]

[example]

Therefore a double quote becomes " and a single '

[/example]

[reference]

[/reference]

Simple Basic MySql – beginning mysql mysqlshow

[problem]

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

[/problem]

[solution]

Is this demo, I show the options for mysqlshow.

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

[/solution]

[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

 [marcus@bagend ~]$ 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. 

[/example]

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

[/problem]

[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 changed mysql> 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) 

[/example]

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.

[/problem]

[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... 

[/solution]

[example]

Here is a demo:

 # java Arguments -a -x -y args exec w 3 args argv[0] = -a argv[1] = -x argv[2] = -y 

[/example]

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.

[/problem]

[solution]

Below is the typical ‘hello world’ script

[/solution]

[example]

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

[/example]

[reference]

Microsoft technet tips on beginning vb scripting

[/reference]

Switch to a different user in MS Windows / DOS

[problem]

You want to switch user from the MS DOS prompt.

[/problem]

[solution]

Use runas

runas /?

[/solution]

[example]

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

runas /user:USERID@xxx 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" ...

[/example]

Setting file permissions from command line in windows

[problem]

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

[/problem]

[solution]

Use cacls

cacls /?

[/solution]

[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:F PCxxxxxxxxxxxxAdmin:F
  • Modify permissions. Here we are granting full access to the user, replace user with desired user name.
> cacls filename /E /G user:F processed file: C:...filename
  • Here we see the permissions have been reset:
> cacls filename ...filename           PCxxxxxxxxxuser:F NT AUTHORITYSYSTEM:F PCxxxxxxxxxxxxxAdmin:F

[/example]

Useful PHP tool to create an image with superimposed text

[problem]

You want to create an image text label.

[/problem]

[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.

  

[/solution]

[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.

[/example]

[reference]

[/reference]

[tags]Image, PHP[/tags]