T-SQL implementation of SKIPJACK

This source code is an T-SQL implementation of the crypt algorith SKIPJACK as a user function for MS-SQL 2000.

Requirements

1. MS SQL 2000
2. Script is case insensitive

Files

Run_Me_First.sql Init script
SkipJack_Crypt.sql Crypt functions
SkipJack_Dec.sql Decrypt functions
samples.sql Samples
Support_functions.sql Utility functions
customer.csv CSV file for import and crypt data

Installation

  1. Run SQL Query Analyzer
  2. Logon as Administrator or sa
  3. Use master database (recomanded)
  4. Open Run_Me_First.sql and run it (press F5)
  5. Open support_functions.sql and run it
  6. Open SkipJack_Crypt.sql and run it
  7. Open SkipJack_Dec.sql and run it

Support functions

NameParametersReturnExample
ExponentialRoot (integer), Exponent(integer) Big IntegerExponential(2,3)=2^3=8
SHL *Number1 (integer), Number2 - (integer)Big IntegerSHL(5,10)=5*2^10=5120
SHR *Number1 (integer), Number2 - (integer)Big IntegerSHR(17,2)=17\2^2=4
StrToNumString (char[2])IntegerStrToNum(‘AB’)=16706
NumToStrNumber (integer)String (char[2])NumToStr(16706)=’AB’

* SHL = bitwise shift left, SHR = bitwise shift right

Examples

Print dbo.Exponential(2,3)
Print dbo.SHL(5,10)
Print dbo.SHR(17,2)
Print dbo.StrToNum('AB')
Print dbo.NumToStr(16706)


Crypt

NameParametersReturn
CryptTextPlain Text (nvarchar[4000]), crypt key (nvarchar[10]) Crypt text nvarchar(4000)

Sample

Print dbo.CryptText('Hello World!','Some key')

Decrypt

NameParametersReturn
DeCryptTextCrypt Text (nvarchar[4000]), crypt key (nvarchar[10]) Decrypt text nvarchar(4000)

Sample

Declare @C nvarchar(4000)
Set @C=dbo.CryptText('Hello World!','Some key')
Print dbo.DeCryptText(@C,'Some key')

For more examples, see sample.sql

Note

Computing size of a crypt text:

Length (Crypt text) = Length (Plain Text) + (Length (Plain text) MOD 8)

You might also like...

Comments

David Janecka T-SQL,ASP, C++

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.” - Donald Knuth