⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dots.cpp

📁 safenet加密编程Demo,圣天狗是加密狗的极品,安全性非常高,合理的利用他的加密算法和工具会大大提高加密的强度
💻 CPP
字号:
/*******************************************************************/
/*                                                                 */
/*      Copyright (C) 2006 SafeNet, Inc.                           */
/*                    All Rights Reserved                          */
/*                                                                 */
/*******************************************************************/

/*C******************************************************************
* FILENAME    : dots.cpp
* DESCRIPTION : 
*             Simple demonstration of Sentinel Keys 1.0.1 library calls.
*             
*             This is ECC sign and verify based application.This program assumes that 
*             an ECC algo has been programmed into the key by Sentinel Keys toolkit.
*   
*C*/

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include "sentinelkeyslicense.h"

#define sleep(A) _sleep(A*100)

#define HDR_DEMO_PROG_STR           "\n       %s %s Demonstration Program\n"
#define PROD_NAME_STR               "Sentinel Keys"
#define VERSION_STR                 "1.0.1"
#define COPYRIGHT_STR               "          Copyright (C) 2006 SafeNet, Inc.\n\n"

# define DOTS_CLEAN(C)  printf("\n"); return(C);


/************************************
* Enrty Point : main 
*************************************/
int main()
{
    SP_HANDLE           licHandle;               /* Sentinel Keys license handle */
    SP_DWORD            devID;                   /* Developer Id */
    SP_STATUS           status;
    SP_DWORD            flags = 0;
    SP_BYTE             signBuffer[] = "Copyright (C) 2006 Safenet Inc";
    SP_BYTE             signResult[42]; /*Max result len is 42  --- chk for the size*/
    SP_DWORD            length = sizeof(signBuffer);
    

    setbuf(stdout, NULL);
    printf(HDR_DEMO_PROG_STR, PROD_NAME_STR,VERSION_STR);
    printf(COPYRIGHT_STR);    

    /* Get the inputs from the user */
    printf("\nEnter Developer ID (in Hex):");
    scanf("%x", &devID );

    /* Get flags */
    flags = SP_STANDALONE_MODE;

    /* Get the license to run the application */
    status = SFNTGetLicense( devID,
                             SOFTWARE_KEY,   /* Software key specified in SentinelKeysLicense.h */
                             LICENSEID,      /* LicenseID specified in SentinelKeysLicense.h */
                             flags,
                             &licHandle );   
    if( status != SP_SUCCESS)
    {
        printf("\nFailed to get license. Return code: %d.", status );
        return -1;
     }

    

    memset(signResult,0,sizeof(signResult));        
    status = SFNTSign(licHandle,
                      SP_LICENSESIGNANDVERIFY_ECC,
                      signBuffer,
                      length,
                      signResult);

    /* If Signing fails, release the license and exit */
    
    if( status != SP_SUCCESS)
    {
        printf( "\nSigning of Data failed. Return code: %d.", status);
        SFNTReleaseLicense(licHandle);
        return -1;
    }else
        printf("\n Successfully signed data ");

    status = SFNTVerify(licHandle,
                        PUBLIC_KEY_SP_LICENSESIGNANDVERIFY_ECC,
                        signBuffer,
                        length,
                        signResult);

    if( status != SP_SUCCESS)
    {
        printf( "\nVerification of Data failed. Return code: %d.", status );
        SFNTReleaseLicense(licHandle);
        return -1;
    }else
        printf("\n Successfully verified data");


    /* Release license before terminating */
    SFNTReleaseLicense(licHandle);

    DOTS_CLEAN(0);
} /* end main */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -