Technical Forum

Hi,
You can post your technical queries in the form of comments in this page... Myself or any visitor of the site can try to post solution for your query...

3 comments:

Anonymous said...

Hi,
Could anyone please provide solution for the below:


(1, 1) (3, 11) (5, 101) (7, 111) (9, 1001) (11, 1011)

In the pattern of number/digits pairs above there is a common relationship between each of the pairs and a pattern.

1. Need to recognize the commonality and the pattern
2. Write a SQL function to take 2 inputs. 1st input takes the number of pairs to print, 2nd input should be the starting number in the series of pairs. Print the pairs having the above pattern and commonality between the pairs. The above example has 6 pairs and starting number of the series is 1.

Thanks,
SQL Learner

Kiran said...

Hii..

Hope the below SQL Server Stored procedure do the trick…


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Kiran Kumar Chandaka
-- Create date: 16th Dec 2010
-- Description: Generate the Number pair of pattern (1, 1) (3, 11) (5, 101) (7, 111) (9, 1001) (11, 1011)
-- =============================================
ALTER PROCEDURE GenerateNumbersPatternPairs
-- Add the parameters for the stored procedure here
@NumberOfPairs INT,
@StartingNumber INT
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- INTerfering with SELECT statements.
SET NOCOUNT ON;
Declare @tempNumberOfPairs INT,@TempStartingNumber INT, @CountVar INT
DECLARE @BinaryVariable2 BINARY(1000)
DECLARE @Output NVARCHAR(MAX), @BitRepresenntation varchar(32) /* SQL Server int is 32 bits wide */
SET @tempNumberOfPairs = @NumberOfPairs
SET @TempStartingNumber = @StartingNumber
SET @CountVar = 0
SET @Output = ''
WHILE @CountVar < @tempNumberOfPairs
BEGIN

set @BitRepresenntation = ''
DECLARE @TempInt INT
SET @TempInt = @TempStartingNumber
while 1 = 1 begin
select @BitRepresenntation = convert(char(1), @TempInt % 2) + @BitRepresenntation,
@TempInt = convert(int, @TempInt / 2)
if @TempInt = 0 break
end

SET @Output = @Output + '(' + CONVERT(NVARCHAR(20), @TempStartingNumber) + ',' + @BitRepresenntation + ')'
SET @TempStartingNumber = @TempStartingNumber + 2
SET @CountVar = @CountVar+1
END
PRINT @Output
-- GenerateNumbersPatternPairs 9,1
END
GO


Thanks,
Kiran

Anonymous said...

Sign PE file with certificate by programing



Someone needs this function, so I post it.

First, you need to create a *.cer and *.pvk by makecert.exe.






#include
#pragma comment (lib, "Cryptui.lib")

//////////////////////////////////////////////////////////////////////////////////////////////////
//
// Function: SignFile
//
// Purpose: Sign PE file with certificate. (*.pvk and *.cer)
//
// Arguments:
// pszExeFile [in] The PE file name.
// pszPvkFile [in] The private key file name. (*.pvk)
// pszCertFile [in] The certificate file name. (*.cer, *.spc)
//
// Returns:
// If success, return TURE.
//
// Notes:
//
// Last modified: 2009.01.20

BOOL SignFile(LPTSTR pszExeFile, LPTSTR pszPvkFile, LPTSTR pszCertFile)
{
CRYPTUI_WIZ_DIGITAL_SIGN_INFO signInfo;
CRYPTUI_WIZ_DIGITAL_SIGN_CERT_PVK_INFO pvkInfo;
CRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE_INFO pvkFileInfo;
BOOL bResult;

pvkFileInfo.dwSize = sizeof(CRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE_INFO);
pvkFileInfo.pwszPvkFileName = pszPvkFile;
pvkFileInfo.pwszProvName = NULL;
pvkFileInfo.dwProvType = PROV_RSA_FULL;

pvkInfo.dwSize = sizeof(CRYPTUI_WIZ_DIGITAL_SIGN_CERT_PVK_INFO);
pvkInfo.pwszSigningCertFileName = pszCertFile;
pvkInfo.dwPvkChoice = CRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE;
pvkInfo.pPvkFileInfo = &pvkFileInfo;

signInfo.dwSize = sizeof(CRYPTUI_WIZ_DIGITAL_SIGN_INFO);
signInfo.dwSubjectChoice = CRYPTUI_WIZ_DIGITAL_SIGN_SUBJECT_FILE;
signInfo.pwszFileName = pszExeFile;
signInfo.dwSigningCertChoice = CRYPTUI_WIZ_DIGITAL_SIGN_PVK;
signInfo.pSigningCertPvkInfo = &pvkInfo;
signInfo.pwszTimestampURL = NULL;
signInfo.dwAdditionalCertChoice = CRYPTUI_WIZ_DIGITAL_SIGN_ADD_CHAIN;
signInfo.pSignExtInfo = NULL;

bResult = CryptUIWizDigitalSign(CRYPTUI_WIZ_NO_UI, NULL, NULL, &signInfo, NULL);

return bResult;

} // SignFile()

Post a Comment