In SQLCMD and Powershell I wanted to take the list of databases. In MySQL “show databases” command was there. But in SQLCMD I was unable to find such a command.
SELECT Name FROM master.dbo.sysdatabases
You can use above commands in SSMS (if you are lazy to move your mouse to object explorer) and SQLCMD. Also you can use same thing on PowerShell too.
Invoke-SQLCMD "EXEC sp_databases"
Invoke-SQLCMD "SELECT Name FROM master.dbo.sysdatabases"
But in SQLPS you can go to your SQL Server instance’s database and just type “dir”.
If you have so many documents in your collection in MongoDB database. Sometimes you may want to retrieve few documents. But if we run find() we cant have nice output. You may need to have nice indentation and line breaks. You may want results in more readable way. Then you can use pretty().
Who can read this??
If you use pretty() you can take nice output with Mongo Shell.
I was always amazed by secret messages and Cryptography is the science applied for this. Modern cryptography has gone to a high standard as it’s bonded with mathematics, computer science and electrical engineering. I thought of giving a basic idea about classic cryptography for a change.
There are three methods in classic cryptography.
- concealed messages (Steganography) – These hidden messages are written in invisible ink,microdots etc.
- Codes – Here words or phrases are represented by predetermined words,numbers or symbols which were included in code books.
- Ciphers – I feel this as the most challenging method in classic cryptography. In this context individual letters are disguised using various techniques.Basically this is divided in to 2.
-> Substitution ciphers
-> Transposition ciphers
I’ll give a brief idea about these 2 techniques.
Here letters in the message can be replaced with numbers,other letters,symbols or combinations of all these.Simple substitution cipher and multiple substitution cipher comes under this.
- Simple substitution cipher –
Can you understand the cipher text above?
It’s basically the simplest substitution that can be used. Each number stands for the letters of English alphabet in alphabetical order. We can see that the deciphered text is “HELP“.
And also we can have a special cipher alphabet corresponding to the letters in the normal alphabet and encode.
- Multiple substitution cipher –
Message has to encode using a key word in multiple substitution.
If we want to encode the message “Send a rescue team soon” with the key word “five” following steps should be followed.
First match up key words with the letters of the message.s-e-n-d-a-r-e-s-c-u-e-t-e-a-m-s-o-o-n
f i v e f i v e f i v e f i v e f i v
Then follow the steps below taking the corresponding letters.
If we take the first corresponding pair, s-19th letter and f-6th letter -> s+f=25 -> 25th letter-y
When it comes to the 3rd pair it’s a bit different.
n-14th letter and v-22nd letter -> n+v=36
As 36>26, 36-26=10 take the 10th letter “j”
Like that we have to encrypt all the letters in the message.Final cipherd text would be “ynjigaaxidaykjixuxj “
In this method letters in a message are jumbled and arranged in a block according to a secret scheme.Mostly this is done in a geometric design.
If we want to encode the message “Meet me in the usual place at 10 tonight” it can be done as below in the simplest way.
Transposition cipher when arranged in a rectangle is called a columnar cipher.It can be encoded using a key word.
If we want to cipher the message “I need help” following steps should be followed.
First arrange the message in a rectangular block.
Then a key word must be chosen to assign a number to each column in the rectangle.If we select the key word “CAT” each letter is assigned a column of letters as below.
As C-3rd letter, A-1st letter, T-20th letter ,
the alphabetical order of the key word will be A,C,T.
So when encoding we have to take the column under A first, then the column under C,finally the column under T.
It’ll give the final output,
These techniques can be developed in more complex ways too though I gave simple examples. Hope you got a basic idea about the techniques that were used in classic cryptography.