Library code snippets

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)

Comments

  1. 01 Jan 1999 at 00:00

    This thread is for discussions of T-SQL implementation of SKIPJACK.

Leave a comment

Sign in or Join us (it's free).

David Janecka T-SQL,ASP, C++

Related podcasts

  • Stack Overflow: Podcast #28

    This is the twenty-eighth episode of the StackOverflow podcast, where Joel and Jeff discuss Windows Azure, SQL Server 2008 full text search, Bayesian filtering, porn detection, and project management — among other things. Jeff met the inestimable Joey DeVilla aka Accordion Guy...

We'd love to hear what you think! Submit ideas or give us feedback