![]()  | 
  
Chilkat  HOME  Android™  AutoIt  C  C#  C++  Chilkat2-Python  CkPython  Classic ASP  DataFlex  Delphi DLL  Go  Java  Node.js  Objective-C  PHP Extension  Perl  PowerBuilder  PowerShell  PureBasic  Ruby  SQL Server  Swift  Tcl  Unicode C  Unicode C++  VB.NET  VBScript  Visual Basic 6.0  Visual FoxPro  Xojo Plugin
 
      (SQL Server) WPA Key Calculation from PassPhrase to HexDemonstrates how to calculate a WPA key from a passprhase and network SSID. 
 -- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int -- This example assumes the Chilkat API to have been previously unlocked. -- See Global Unlock Sample for sample code. DECLARE @crypt int -- Use "Chilkat_9_5_0.Crypt2" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.Crypt2', @crypt OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @wpaHexKey nvarchar(4000) -- The "ps" is the WPA passphrase DECLARE @pw nvarchar(4000) SELECT @pw = 'password' DECLARE @pwCharset nvarchar(4000) SELECT @pwCharset = 'ansi' -- Hash algorithms may be: sha1, md2, md5, etc. DECLARE @hashAlg nvarchar(4000) SELECT @hashAlg = 'sha1' -- Specify the SSID in hex: -- For example, if the SSID is "ABC", then the -- hex values for these us-ascii chars is "414243" DECLARE @ssidHex nvarchar(4000) SELECT @ssidHex = '414243' -- The WPA key calculation will always use 4096 iterations. DECLARE @iterationCount int SELECT @iterationCount = 4096 -- The WPA hex output should be 256 bits. DECLARE @outputBitLen int SELECT @outputBitLen = 256 -- Indicate that "hex" is to be returned. DECLARE @enc nvarchar(4000) SELECT @enc = 'hex' EXEC sp_OAMethod @crypt, 'Pbkdf2', @wpaHexKey OUT, @pw, @pwCharset, @hashAlg, @ssidHex, @iterationCount, @outputBitLen, @enc PRINT @wpaHexKey EXEC @hr = sp_OADestroy @crypt END GO  | 
  ||||
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.