Numbering method for sealing numbers first and then unsealing numbers
The digital lottery method uses image encryption to ensure transparent and tamper-proof lottery results, addressing transparency issues and enhancing public trust.
Patent Information
- Application Number
- CN202410471280.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2024-01-13
- Filing Date
- 2024-04-19
- Publication Date
- 2025-07-15
AI Technical Summary
The existing lottery lottery machines have the risk of manipulating the winning numbers, resulting in a lack of fairness and transparency, affecting sales and social order.
A digital lottery machine is used to capture image data through a camera, and an encryption technology is used to generate a password and file. After the account is blocked, the image data is encrypted into a ciphertext. When unblocking, the password is used to decrypt the winning number, and the display disclosure process ensures that the winning number cannot be modified.
The lottery process is realized to ensure that the lottery number is fixed once it is determined and cannot be modified, which enhances fairness and transparency.
Smart Images

Figure CN120318947A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a method for encrypting a digital image using digital technology, and generating a lottery winning number with the digital image as seed information after the confidentiality period, so as to implement a virtual ball lottery method of first sealing and then unsealing. Background Art
[0002] Currently, most lottery machines use rotating rods to stir or upward jets of air to drive the balls to conduct the lottery. Many people think that there are irregularities in the existing lottery drawing, and even believe that when drawing the lottery, someone will secretly manipulate the winning numbers of the lottery according to the lottery sales results, resulting in the loss of confidence of lottery players in the fairness and transparency of the lottery. This not only affects the sales volume of the lottery, but even disrupts social order. Therefore, this article advocates using a lottery method of first sealing and then unsealing to achieve the openness and transparency of the lottery drawing process. The lottery method in the present invention can be applied not only to lottery drawing, but also to lottery activities such as the examination seats of candidates, the arrangement of primary school student degrees, the allocation of affordable housing, vehicle license plates, and new stock distribution. Summary of the Invention
[0003] The method in the present invention is realized by utilizing the randomness of the image data in the photos taken by the camera on the computer and the encryption technology of digital information. The computer that uses the method in the present invention for lottery drawing is a digital lottery drawing machine (the lottery drawing machine mentioned hereinafter all refers to the digital lottery drawing machine that uses the method in the present invention for lottery drawing). After the sealing time arrives, the lottery drawing machine calls the camera to take a photo, randomly selects one photo from the taken photos, then randomly copies the image DP from the photo, and generates the sealing password DK. Then, the image DP is encrypted by using the password DK with a predetermined encryption algorithm to generate the file EF. Next, the ciphertext information in the file EF is output to the display, and the sealing password DK is output to the display after the decryption time arrives. The file EF is decrypted by using the sealing password DK to obtain the image DP. Finally, the winning number is generated according to the predetermined lottery drawing algorithm with the image DP as the seed data, and the winning number and the image DP are output to the display. After the lottery drawing software in the lottery drawing machine is installed and started, under the condition that the parameters such as the virtual ball combination mode have been set, the lottery drawing machine runs under the condition of a single machine without external intervention (the manufacture of the lottery drawing machine to achieve this condition has been separately filed for an invention application). At this time, the lottery drawing algorithm in the lottery drawing software has been determined. Since the winning number is based on the image DP as the seed data, once the data in the image DP is determined, the winning number is also determined. And because the image DP is encrypted by the password DK to generate the file EF and the ciphertext is publicly displayed through the display, the on-site or remote audience can receive the file EF through a computer with a camera. When the unsealing time arrives, the sealing password DK is output to the display, and the on-site or remote audience can also receive the password DK through a computer with a camera and decrypt the file EF to obtain the image DP and calculate the winning number. The on-site or remote audience can not only compare and verify the winning number with the officially announced winning number, but also compare and verify the seed data image DP obtained by decrypting the file EF on their own computer with the officially announced seed data image DP, so as to ensure that once the image DP is encrypted to generate the file EF and the ciphertext is made public, the plaintext in the file EF is fixed, that is, the image DP is fixed, so as to ensure that the winning number is fixed after sealing, that is, to ensure that the winning number cannot be modified, and once it is modified, it will be discovered. The lottery drawing software that uses the method in the present invention for each lottery draw (time) is divided into four processes: waiting, sealing, waiting, and unsealing.
[0004] The virtual ball combination method described in this article refers to one of the following three: ① The method of drawing M0 natural numbers (i.e., the virtual ball numbers drawn) from the specified N0 natural numbers (i.e., the virtual ball numbers participating in the lottery draw) as the winning numbers; ② Executing method ① twice, that is, drawing M1 natural numbers from the specified N1 natural numbers as the first part of the winning numbers; and then drawing M2 natural numbers from the specified N2 natural numbers as the second part of the winning numbers. ③ Executing method ① multiple times. The winning numbers described in this article refer to the numbers composed of the virtual ball numbers calculated by the software using the method of the present invention. In addition, in order to make the number of digits of the natural numbers in the winning numbers uniform, 0 can be added before the natural numbers. For example, under the condition of drawing 7 natural numbers from 1 to 36 natural numbers, if the drawing result of a certain time is 3, 6, 15, 18, 21, 29, 32, it can be displayed as 3, 6, 15, 18, 21, 29, 32 or 03, 06, 15, 18, 21, 29, 32.
[0005] See Figure 1 , the general working process of the lottery draw method in the present invention is as follows: 【1】. Start the lottery draw software and initialize it; 【2】. Read the image from the camera and output it to the display; 【3】. Determine whether it has reached the account sealing time point. If it has, execute step 【4】; otherwise, return to step 【2】; 【4】. Read a frame of image SP from the camera and randomly copy the image from image SP to obtain an image DP identical to the copied area; 【5】. Generate the account sealing password DK, and then use this password to encrypt the image DP using a predetermined encryption algorithm to generate the file EF; 【6】. Cut the ciphertext information in the file EF into N small segments, and output these information segments to the display one by one at a certain time interval; 【7】. Read the image from the camera and output it to the display; 【8】. Determine whether the time has passed the confidentiality period. If it has, execute step 【9】; otherwise, return to step 【7】; 【9】. Output the account sealing password DK to the display, decrypt the file EF with the account sealing password DK to obtain the image DP, and then generate the winning numbers according to the predetermined lottery draw algorithm with the image DP as the seed data, and output the winning numbers and the image DP to the display;
[10] . Output some information related to this lottery draw to the display and wait for a certain period of time, and then execute step 【2】.
[0006] The startup and initialization of the lottery software described in this article include the following: The operator starts the lottery software in the lottery machine, completes parameter settings, and the lottery software runs the working thread CAP that accesses the camera and runs the lottery thread. Among them, the completion of parameter settings is one of the following three: ① The operator sets the user password, virtual ball combination method, lottery period, current issue number, confidentiality duration after sealing, the starting time point of the first sealing after this software runs, sets the business information provided by the lottery organizer, and then the operator commands the lottery software to enter the automatic cyclic lottery process without manual intervention. After receiving the command, the lottery software first determines whether the operator's settings are valid. If invalid, it returns to the setting interface and prompts the operator to reset. If valid, it accepts the parameters set by the operator; ② The lottery software sets the user password, virtual ball combination method, lottery period, current issue number, confidentiality duration after sealing, the starting time point of the first sealing after this software runs, and sets the business information provided by the lottery organizer according to the default parameters and internal rules of the software; ③ The operator only sets some of the parameters involved in ①, and the remaining parameters are determined by the lottery software according to the default parameters and internal rules of the software.
[0007] Among them, steps [4] to [6] are the sealing process, steps [9] and
[10] are the unsealing process, steps [2] and [3] are the processes of waiting for sealing, and [7] and [8] are the processes of waiting for unsealing.
[0008] The meaning of "random" in "randomly copy from image SP" is that the positions of the vertices in the image copying area are random.
[0009] The generated sealing password DK generates a random password using one or more of the following data as seed data: ① Data randomly appearing inside the system; ② Data transmitted from the camera; ③ Data in image DP; ④ Data obtained by compressing image DP.
[0010] The predetermined encryption algorithm consists of one or more of the following encryption algorithms: substitution, permutation, confusion, diffusion, iteration, combination splitting method, mathematical relationship encryption, transposition encryption, logical encryption, arithmetic encryption, block encryption, stream cipher encryption, linear encryption, non-linear encryption, symmetric encryption, asymmetric encryption, statistical data encryption, pseudo-random encryption algorithm, the algorithm of stream cipher encryption generated by a polynomial that increases the number of terms and adjusts the power as the encryption process progresses, and the algorithm of encryption using the serial number code generated by sorting. As can be seen from the above, common symmetric encryption algorithms such as DES, 3DES, AES, RC4, Blowfish, etc. also belong to the above-mentioned predetermined encryption algorithms.
[0011] The generation of the encrypted file EF from the image DP is one of the following two methods: ① encrypt the data in the image DP and save the ciphertext generated during the encryption process as the file EF; ② encrypt the image data obtained after compressing the image DP and save the ciphertext generated during the encryption process as the file EF.
[0012] The output to the monitor in step [6] is one of the following three methods: ① output to the monitor and display it on the screen of the monitor in text form; ② output to the monitor and display it on the screen of the monitor in the form of a QR code; ③ output to the monitor and display it on the screen of the monitor both in text form and in the form of a QR code.
[0013] The generation of the winning number by using the image DP as the seed data according to a predetermined lottery algorithm means an algorithm that uses the feature code of the image DP to perform a modulo operation on the relevant combination numbers in the virtual ball combination method according to rules and convert them into the winning number. The feature code of the image DP is one of the following two: ① the feature code of the data in the image DP; ② the feature code of the image data obtained after compressing the image DP. The feature code mentioned in this article refers to the numerical value, i.e., the digital digest, obtained by calculating all the data in the specified information using a predetermined feature code algorithm. The predetermined feature code algorithm consists of one or more of the following algorithms: hash algorithm, symmetric encryption algorithm, and asymmetric encryption algorithm. The hash algorithm mentioned in the previous sentence consists of one or more of the following algorithms: substitution, permutation, confusion, diffusion, iteration, combination and splitting method, mathematical relation operation, transposition operation, logical operation, arithmetic operation, grouping operation, linear operation, non-linear operation, and pseudo-random operation. Obviously, the MD5 algorithm and the SHA hash algorithm are hash algorithms.
[0014] The said several times must be less than the time length from the next account sealing moment to the current moment.
[0015] The lottery machine adopting the method in the present invention usually does not allow to establish wired communication with the outside world, nor does it allow to establish wireless communication with the outside world. However, since the method in the present invention outputs the ciphertext and the password to the monitor, we can write a dedicated verification software for reading the information displayed on the monitor to receive the ciphertext and the password and complete the lottery verification work.
[0016] See Figure 2 The general verification process matching the method in the present invention is as follows: 【1】 Run the verification software APP; 【2】 Scan the images obtained by photographing the monitor of the lottery machine from the front at the time of account sealing, and parse N small fragments split from the file EF from these images, and then use these small fragments to recombine into the file EF; 【3】. Scan the images obtained by photographing the lottery machine display from the front during unsealing, parse the password DK from these images, then use the password DK to decrypt the file EF to obtain the image DP, generate the winning numbers according to a predetermined lottery algorithm using the image DP as the seed data, and then output the winning numbers and the image DP to the display.
[0017] In the process of "generating the winning numbers according to a predetermined lottery algorithm" described in the verification process of this article, parameters related to the lottery such as the virtual ball combination method, the lottery period, and the current issue number are required. These parameters can be obtained in two ways: ① Obtained from the identification information, ② Use the default parameters in the verification software APP.
[0018] Comparing the winning numbers calculated by the verification process of this article with the winning numbers publicly announced by the lottery machine can obviously be done manually, or it can be achieved by adding the content of the winning numbers publicly announced by the lottery machine on the basis of the verification process mentioned in this article to complete the comparison by the verification process. In addition, we can add the feature code of the image DP to the password DK, so that a more rigorous verification can be completed by comparing the feature code of the image DP during the process of decrypting the file EF. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 It is a general lottery work flow chart in the present invention; Figure 2 It is a general verification flow chart in the present invention; Figure 3 It is a lottery work flow chart of the first embodiment; Figure 4 It is a verification flow chart of the first embodiment; Figure 5 It is a lottery work flow chart of the second embodiment; Figure 6 It is a verification flow chart of the second embodiment; Figure 7 It is a schematic diagram of the winning numbers output to the display; Figure 8 It is an example diagram of the image DP in the second embodiment; Figure 9 It is an example diagram of the image YP in the second embodiment. DETAILED DESCRIPTION OF THE INVENTION
[0020] Refer to Figure 3 , the first embodiment of the present invention is a lottery method applied to a lottery machine, and its work flow is as follows: 【1】. Start the lottery software and initialize; 【2】. Wait for 30 milliseconds. While waiting, the thread CAP reads the image from the camera and outputs it to the display; 【3】, the lottery software determines whether the account blocking time has arrived. If so, it executes step 【4】, otherwise, it executes step 【2】; 【4】The lottery software reads a frame of image SP from the camera, and randomly copies the image from the image SP to obtain an image DP that is the same as the copy area; 【5】The lottery software generates a blocking password DK, and then uses the password to encrypt the image DP using a predetermined encryption algorithm to generate a file EF, and calls the public key to encrypt and save the blocking password DK; 【6】The lottery software divides the ciphertext information in the file EF into N small segments, adds identification information to each of the divided information segments, and outputs the small segments with identification information added to the display in the form of QR codes and text at a certain time interval. After all N small segments are displayed, the next step is executed; 【7】, Wait for 30 milliseconds. While waiting, thread CAP reads the image from the camera and outputs it to the display; [8] The lottery software determines whether the confidentiality period has expired. If so, execute step [9]; otherwise, execute step [7]; [9] The lottery software calls the private key to decrypt the sealing password DK, then uses the sealing password DK to decrypt the file EF to obtain the image DP, and uses the identification information and the sealing password DK to generate the unblocking announcement information, and then outputs the unblocking announcement information to the display in the form of a QR code and text, and uses the image DP as the seed data to generate the winning number according to the predetermined lottery algorithm, and outputs the winning number and the image DP to the display;
[10] The lottery software outputs some information related to the lottery to the display, waits for a certain period of time, and then executes step [2].
[0021] The identification information described in this article is composed of one or more of the following information: ① ciphertext mark; ② password mark; ③ parameter mark; ④ number of fragments; ⑤ fragment sequence number; ⑥ information length; ⑦ feature code; ⑧ file length; ⑨ parameters set when the software is initialized.
[0022] The information related to the lottery described in this article is composed of one or more of the following information: ① feature code; ② parameters set when the software is initialized.
[0023] In this embodiment, the lottery method is mainly implemented by software. When writing the lottery software, there are many programming tools for us to choose from. There are no insoluble technical problems in each implementation step of the lottery workflow, and they can all be solved by inputting code according to the current programming technology. Since the software interface is very easy to implement, it is not necessary to describe the implementation of this step here. Therefore, the following mainly provides a simple code example verified in the WIN10 computer system for the workflow using Microsoft Visual C++ 2010 code as follows:
[0024] #pragma once #include "cap.h" / / Header file of the video capture class CCap downloaded from the Internet #include "afxwin.h" / / CYHTestDlg dialog box class CYHTestDlg : public CDialogEx,public IMediaReceiver { public: CYHTestDlg(CWnd* pParent = NULL); / / Standard constructor enum { IDD = IDD_YHTEST_DIALOG}; / / Dialog box data protected: virtual void DoDataExchange(CDataExchange* pDX); / / DDX / DDV support / / Implementation protected: HICON m_hIcon; / / Generated message map function virtual BOOL OnInitDialog(); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); DECLARE_MESSAGE_MAP() public: afx_msg void OnBnClickedOk(); / / Command to enter the automatic loop lottery draw process protected: void OnUpdateVideo(const BITMAPINFO *pBmi, const BYTE *pBuf); / / Update video image friend DWORD WINAPI YH_Thread(LPVOID pParam); / / Loop lottery draw thread CCap *pCapDevice; / / Camera video capture object, i.e., thread CAP object HWND m_hDlg; / / Dialog box handle public: HDC hDC; CClientDC *pVideoDC; int m_DevNum; CStatic VideoView; / / Video display CStatic YHPhotoView; / / Display image DP when unsealing CStatic mShowBallsCtrl; / / Display winning numbers CStatic XS_EWM; / / Display QR code CTime EPlanTime; / / Sealing time CTime DPlanTime; / / Unsealing time CTimeSpan EDTermLoop; / / Lottery draw cycle CTimeSpan EDProtectTerm; / / Confidentiality duration after sealing void InitYHParam(); / / Important parameter initialization void ShowYHText(BYTE*pEPicBuf,int BufLen,const TCHAR* FlagStr); / / Display information after the lottery draw picture is sealed void PublicYHPhoto(CImage *img); / / Display image DP void ShowYHResultOnDC(unsigned _int64 mTermNum); / / Display the period number and winning / / Number void ShowVideo(int mSel); / / Open the camera with the serial number mSel and create a loop lottery thread void YH_ThreadCore(); / / Main function of loop lottery void ShowQRCode(const TCHAR*pCodeInfo); / / Generate a QR code using the Qrcode object and display it on the control XS_EWM void ReadyShowItem(TCHAR*pPrompt,unsigned _int64 mTermNum); / / Clear the old information and display the new prompt };
[0025] #include "stdafx.h" #include "YHTest.h" #include "YHTestDlg.h" #include "afxdialogex.h" #include "qrencode.h" / / Header file for generating QR codes downloaded from the network #include <cmath> #include <gdiplus.h> ………… HANDLE pThreadHandle = NULL; const BITMAPINFO * pDevBmi=NULL; const BYTE *pDevBuf=NULL; CYHTestDlg*pYHTestDlg; GdiplusStartupInput m_gdiplusStartupInput; ULONG_PTR m_gdiplusToken; CImage *m_pImage; CImage SPZP; CImage DPic; BYTE* pEImgFileMem=NULL; BYTE pRSA_EPass
[2048] ; BYTE pRSA_DPass
[2048] ; int mImgEBufLength=0; int mRandPassLen; int mRSAPassLen; int MaxLimit,mBallNum; bool bCanSame,bCanZero; CString YHResult=L""; CFont mBallFont; CFont mETextFont; unsigned _int64 mTermNum=0; ………… / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / void CYHTestDlg::DoDataExchange(CDataExchange* pDX) { / / Control binding CDialogEx::DoDataExchange(pDX); DDX_Control(pDX, IDC_VIDEO, VideoView); DDX_Control(pDX, IDC_ShowDImage, YHPhotoView); DDX_Control(pDX, IDC_DisplayStr, mShowBallsCtrl); DDX_Control(pDX, IDC_EWM, XS_EWM); } / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / void CYHTestDlg::InitYHParam() / / Step [1] Default parameter setting { ………… / / And only display important parameter initialization here CTime mCurtime = CTime::GetCurrentTime(); EDTermLoop = CTimeSpan(0, 0, 2, 0); EDProtectTerm = CTimeSpan(0, 0, 1, 0); EPlanTime = mCurtime + CTimeSpan(0, 0, 0, 10); DPlanTime = EPlanTime + EDProtectTerm; MaxLimit = 36; mBallNum = 7; bCanSame = false; bCanZero = false; } / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / BOOL CYHTestDlg::OnInitDialog() { ………… InitYHParam(); / / Step [1] Default parameter setting ………… } / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / DWORD WINAPI YH_Thread(LPVOID pParam) / / Loop the wire shaking thread { pYHTestDlg->YH_ThreadCore(); / / Loop lottery main function return 0; } / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / void CYHTestDlg::ShowVideo(int mSel) { / / Open the camera with the serial number mSel and run the working thread CAP that accesses the camera, / / And create a loop lottery thread static int m_SelDevSerial=-1; if(m_SelDevSerial>=0) { pCapDevice->ContinueRun(m_SelDevSerial); return; } HRESULT hr = pCapDevice->Init(mSel,VideoView.m_hWnd); if(SUCCEEDED(hr)) { / / Start displaying images if(pCapDevice->Pause()) { if(SUCCEEDED(pCapDevice->Run())) / / Run thread CAP in step [1] { m_SelDevSerial=mSel; CreateThread(NULL,0,YH_Thread,this,0,NULL); / / / / Create and run the loop lottery thread in step [1] }}} else { pCapDevice->Release(); delete pCapDevice; pCapDevice=NULL; } } / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / void CYHTestDlg::OnBnClickedOk() / / Command to enter the automatic loop lottery drawing process { CWnd* pVideoWnd = GetDlgItem(IDC_VIDEO); pVideoDC = new CClientDC(pVideoWnd); int nCount = 0; pCapDevice = new CCap; pCapDevice->GetSampleCB()->SetReceiver(this); hDC = pVideoWnd->GetDC()->m_hDC; / / Enumerate video capture devices nCount = pCapDevice->EnumDevices(); if (nCount > 0) ShowVideo(0); / / Directly start displaying the video, default to select the first device m_DevNum = nCount; } / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / void CYHTestDlg::YH_ThreadCore() / / Main function for loop lottery drawing { / / Before calling this function, the camera video thread needs to be bound to the VideoView control while (1) / / Loop from step [2] to step
[10] { mTermNum++; / / Period number VideoView.ShowWindow(SW_SHOW); / / Display the camera video control so that when waiting in the next / / loop body, the video captured by the camera can be displayed simultaneously while (1) / / Loop from step [2] to step [3] { Sleep(30); if (CTime::GetCurrentTime() > EPlanTime) break; } VideoView.ShowWindow(SW_HIDE); / / Hide the camera video control to hide the camera / / The picture taken by the camera is conducive to encrypting and protecting the image data ReadyShowItem(L"is blocking the account",mTermNum); / / Clear the result of the last lottery and prompt int BufLen; if(pEImgFileMem)delete[]pEImgFileMem; BYTE*pRandPicMem=CopyRandImg(BufLen); / / Step [4] pEImgFileMem=new BYTE[BufLen+64]; const BYTE*pE_DK_Pass= EPhotoBuf(pRandPicMem, pEImgFileMem, BufLen); / / Step [5] delete[]pRandPicMem; ShowYHText(pEImgFileMem,BufLen,L"YHEIMGTEXT"); / / Step【6】 mImgEBufLength=BufLen; VideoView.ShowWindow(SW_SHOW); / / Show the camera video control so that you can / / While waiting in the loop, the camera image is displayed at the same time while(1) / / loop from step [7] to step [8] { Sleep(30); if(CTime::GetCurrentTime()>DPlanTime) break; } ReadyShowItem(L"Unblocking",mTermNum); / / Clean up the display interface and prompt / / The following lines are steps [9] BYTE*pDK_Pass=RSA_Decrypt(pE_DK_Pass); / / Call the private key to decrypt the seal number password / / DK, RSA encryption algorithm has public code on the Internet BYTE* pDes=DPhotoBuf(pEImgFileMem,pDK_Pass,mImgEBufLength); / / Use password DK to decrypt file EF and get image DP ShowYHText(pDK_Pass,256,L"YHDIMGTEXT"); / / Show the password DK GetYHResult(pDK_Pass,YHResult,MaxLimit,mBallNum,bCanSame,bCanZero); / / Calculate the winning numbers ShowYHResultOnDC(YHResult,mTermNum); / / Show the winning number JPEG_TO_BMP(pDes,mImgEBufLength, &DPic); / / Transfer the image in the buffer pDes to / / Load into CImage object DPic PublicYHPhoto(&DPic); / / Display image DP ShowAboutInfo(); / / Step
[10] displays information related to this lottery draw / / The following lines calculate the next blocking and unblocking time EPlanTime+=EDTermLoop; if(EPlanTime <CTime::GetCurrentTime()) EPlanTime=CTime::GetCurrentTime()+CTimeSpan(0,0,0,10); DPlanTime= EPlanTime +EDProtectTerm; }} The following functions are called directly or indirectly in the YH_ThreadCore function BYTE* CopyRandImg(int &mRandBufLength); / / Step [4], which can be implemented by general programmers const BYTE*RSA_Encrypt(BYTE*pRand_Pass,int mPassLen); / / Call the public key to encrypt the number and password DK. The RSA encryption algorithm can be implemented according to online resources. BYTE* RSA_Decrypt(const BYTE* pE_DK_Pass); / / Call the private key to decrypt the sealed password DK. The RSA encryption algorithm can be implemented according to online resources const BYTE* EPhotoBuf(const BYTE* pSBuf,BYTE*pEDes,int BufLen); / / Step [5], now the encryption algorithm is very mature. In this function, we can use several encryption algorithms in multiple rounds and use a sufficiently long one-time password sealed password DK to ensure the security of the ciphertext. The sealed password DK can be obtained by calculating the hash code and MD5 of the data pSBuf in the image DP (i.e., the buffer) multiple times and then mixing them. In this way, the sealed password DK is also the feature code of the image DP BYTE* DPhotoBuf(const BYTE* pSBuf,BYTE*pPass,int BufLen); / / The decryption function matching the function EphotoBuf can obviously be implemented void JPEG_TO_BMP(BYTE* pJPEGMem,unsigned long BufLen, CImage* pOutImg); / / Load the image in pJPEGMem into the CImage object pOutImg, which can obviously be implemented void CYHTestDlg::ReadyShowItem(TCHAR*pPrompt,unsigned _int64 mTermNum); / / Clear the old information and display the new prompt. For a programmer familiar with Visual C++ 2010 / / This is an easy-to-implement function Void CYHTestDlg::ShowYHText(BYTE*pEPicBuf,int BufLen,const TCHAR*FlagStr) / / Display information in both text and QR code forms { int mSecLen = 800; int mLoopTimes = BufLen / mSecLen; if (BufLen%mSecLen)mLoopTimes++; int mPOs=0; CString ShowStr; CString str; while(mPOs <mLoopTimes) { int mCurShowLength; if(BufLen>mSecLen)mCurShowLength=mSecLen; else mCurShowLength=BufLen; BufLen-=mCurShowLength; mPOs++; ShowStr.Format(L"%s%08X%08X",FlagStr,mPOs,mLoopTimes); for(int i=0;i <mCurShowLength;i++) { str.Format(L"%02X",*pEPicBuf); pEPicBuf++; ShowStr+=str;} SetDlgItemText(IDC_ShowYHText,ShowStr); / / Display ShowStr in text ShowQRCode(ShowStr); / / Display ShowStr with a QR code on the control XS_EWM Sleep(1000); }} void ShowQRCode(const TCHAR*pCodeInfo); / / Use Qrcode object to generate QR code and display it in / / Displayed on the control XS_EWM, general programmers can implement void CYHTestDlg::ShowYHResultOnDC(const TCHAR*YHResult,unsigned _int64 mTermNum=0); / / Display the winning number, which can be implemented by general programmers void CYHTestDlg::PublicYHPhoto(CImage *img); / / Display image DP, general programmers can implement void CYHTestDlg::ShowAboutInfo(); / / Output to display 4 in step
[10] / / Some information related to the lottery draw, such as the lottery draw rules, etc., can be implemented by ordinary programmers int GetYHResult(const BYTE*pPicDataSoul,CString &DesStr,int MaxLimit,int mBallNum,bool bCanSame,bool bCanZero); / / Calculate the winning number / / In fact, there are many algorithms for this function. Here, a relatively simple lottery draw / / algorithm code is as follows: int GetYHResult(const BYTE*pPicDataSoul,CString &DesStr,int MaxLimit, int mBallNum,bool bCanSame,bool bCanZero) { / / pPicDataSoul is the feature code, and its length is not less than mBallNum*sizeof(unsigned int), / / DesStr stores the winning number, MaxLimit is the number of virtual balls placed in the virtual lottery box, mBallNum / / is the number of virtual balls drawn, bCanSame==false means the virtual ball numbers are unique, otherwise they can be repeated, / / bCanZero==true means the smallest virtual ball number starts from 0, otherwise it starts from 1 (or 01) int mReYHResult
[32] ; int mYHBallNum=0; DesStr=L"";bool bIError=false; unsigned int *pSourceInt=(unsigned int *)pPicDataSoul; if(MaxLimit>99||mBallNum<1||(bCanSame==false&&mBallNum>=MaxLimit)) bIError=true; else if(MaxLimit<2||mBallNum<1)bIError=true; if(bIError){AfxMessageBox(L"Parameter setting error"); return mYHBallNum * sizeof(int);} while (mBallNum) { int mTemp = *pSourceInt % MaxLimit; pSourceInt++; if (bCanSame == false && mYHBallNum > 0) { BOOL bFind = TRUE; while (bFind) { for (int i = 0; i < mYHBallNum; i++) { if (mReYHResult[i] == mTemp) { mTemp = (mTemp + 1) % MaxLimit; break; } else if (i + 1 == mYHBallNum) bFind = FALSE; }} for (int i = mYHBallNum - 1; i >= 0; i--) { if (mReYHResult[i] > mTemp) { mReYHResult[i + 1] = mReYHResult[i]; if (i == 0) mReYHResult[0] = mTemp; } else { mReYHResult[i + 1] = mTemp; break;} }} else mReYHResult[mYHBallNum] = mTemp; mBallNum--; mYHBallNum++; } if (bCanZero == false) for (int i = 0; i < mYHBallNum; i++) mReYHResult[i]++; CString sTemp; if ((MaxLimit <= 10 && bCanZero) || MaxLimit < 10) { for (int i = 0; i < mYHBallNum; i++) { sTemp.Format(L"%i", mReYHResult[i]); if(i==0)DesStr=sTemp; else {DesStr+=L"-"; DesStr+=sTemp;} }} else { for(int i=0;i<mYHBallNum;i++) { sTemp.Format(L"%02i", mReYHResult[i]); if(i==0)DesStr=sTemp; else {DesStr+=L"-"; DesStr+=sTemp;} }} return mYHBallNum*sizeof(int); } The program calculates the winning numbers by calling the GetYHResult function. Assuming that the data pointed to by pPicDataSoul is 0X5A500BC5FDB4FC53B6961F8D69E44E4EB627D45E25C80AC3AF58B306, MaxLimit is 36, mBallNum is 7, and both bCanSame and bCanZero are 0, then the function outputs the winning numbers "07-14-19-22-23-27-32" to DesStr. The output form of the winning numbers on the display can be seen in Figure 7 。
[0026] When using the method of the present invention for lottery drawing, this method requires that during the operation of the lottery drawing software on the lottery drawing machine, the lottery drawing machine is always under the monitoring of the camera 24 hours a day, and these monitoring images are live broadcast on the network so that all netizens concerned about the lottery drawing activity can monitor the working status and safety of the lottery drawing machine at any time. At the same time, the verification computer (hereinafter referred to as the verification machine) runs the verification software APP, and the camera of the verification machine continuously captures images of the lottery drawing machine display for the verification machine to scan, analyze and record the verification results.
[0027] See Figure 4 For the verification process of the first embodiment, it is as follows: 【1】. Start the verification software APP; 【2】. The verification software APP reads the QR code from the image data of the camera; [3] If a valid QR code is read, go to step [4]; otherwise, return to step [2]; [4] The verification software APP determines whether the QR code contains the ciphertext fragment in the file EF based on the identification information. If so, the part of the QR code information representing the ciphertext fragment content is converted into binary information and saved to the corresponding position in the buffer TEF, and then executes step [5]. If not, executes step [7]. [5] The verification software APP determines whether all the N small segments split from the file EF have been received. If so, execute step [6]; if not, execute step [2]; [6] The verification software APP saves the ciphertext in the buffer TEF as a file EF, and then executes step [2]; [7], the verification software APP determines whether the QR code is the unblocking announcement information based on the identification information. If so, it extracts the password DK and identification information and executes step [8]. If not, it executes step [2]. [8] The verification software APP uses the password DK to decrypt the file EF. If the decryption is successful, the image DP is obtained and step [9] is executed. Otherwise, step [2] is executed. [9] The verification software APP uses the image DP as seed data to generate the winning numbers according to the predetermined lottery algorithm, and then outputs the winning numbers and the image DP to the display;
[10] If the verification software APP receives an exit signal, it ends; otherwise, it returns to step [2].
[0028] Regarding the code for parsing text and QR codes in images in the verification process, there are already enough resources available on the Internet, and there is no difficult-to-implement technology to implement the code for each step. The function for calculating the winning numbers in the verification process is still the GetYHResult function, so there is no need to provide the implementation code for the verification process in this article.
[0029] See also Figure 5 The second embodiment of the present invention is still a lottery drawing method used in a lottery drawing machine, and its working process is as follows: 【1】Start the lottery software and initialize it; 【2】, Wait for 30 milliseconds. While waiting, thread CAP reads the image from the camera and outputs it to the display; 【3】, the lottery software determines whether the account blocking time has arrived. If so, it executes step 【4】, otherwise, it executes step 【2】; 【4】The lottery software reads a frame of image SP from the camera, and randomly copies the image from the image SP to obtain an image DP that is the same as the copy area; 【5】. The lottery software copies the image DP to obtain an image YP identical to the image DP, then uses the image DP as seed data to generate a winning number according to a predetermined lottery algorithm and writes the winning number into the image YP. Then, it calculates the feature code MD of the data in the image YP, generates a sealing notice message using the identification information and the feature code MD, outputs the sealing notice message to the display in the form of both a QR code and text, generates a sealing password DK using the data in the image DP and the image YP. After that, it encrypts both the image DP and the image YP using the password DK with a predetermined encryption algorithm to generate a file EF, and calls the public key to encrypt and save the sealing password DK; 【6】. The lottery software splits the ciphertext information in the file EF into N small segments, adds identification information to each split small segment of information, and outputs the small segments with the added identification information to the display in the form of both a QR code and text at regular time intervals. After all N small segments are displayed, it proceeds to the next step; 【7】. Wait for 30 milliseconds. While waiting, the thread CAP reads an image from the camera and outputs it to the display; 【8】. The lottery software determines whether the time has passed the confidentiality period. If it has, it executes step 【9】; otherwise, it executes step 【7】; 【9】. The lottery software calls the private key to decrypt the sealing password DK, then uses the sealing password DK to decrypt the file EF to obtain the image DP and the image YP. It then generates an unsealing notice message using the identification information, the sealing password DK, and the feature code MD, and outputs the unsealing notice message to the display in the form of both a QR code and text. It also generates a winning number according to a predetermined lottery algorithm using the image DP as seed data, and outputs the winning number, the image DP (see Figure 8 ) and the image YP (see Figure 9 ) to the display;
[10] . The lottery software outputs some information related to this lottery to the display and waits for a certain period of time, then executes step 【2】.
[0030] Among them, the encryption of both the image DP and the image YP to generate the file EF is one of the following two: ① Encrypt the data of both the image DP and the image YP, and save the ciphertext generated during the encryption process as the file EF; ② Compress the data of both the image DP and the image YP into data DPP, then encrypt the data DPP as the encryption object, and save the ciphertext generated during the encryption process as the file EF.
[0031] Obviously, in the working process of the lottery machine in this embodiment, except for steps 【5】 and 【9】, the rest of the steps are the same as those in the first embodiment. There are no insurmountable obstacles in the implementation code of steps 【5】 and 【9】 in this embodiment, so the implementation of the code in this embodiment will not be elaborated further.
[0032] See also Figure 6 The verification process of the second embodiment is as follows: 【1】、Start the verification software APP; 【2】The verification software APP reads the QR code from the camera’s image data; [3] If a valid QR code is read, go to step [4]; otherwise, return to step [2]; [4] The verification software APP determines whether the QR code contains the ciphertext fragment in the file EF based on the identification information. If so, the part of the QR code information representing the ciphertext fragment content is converted into binary information and saved to the corresponding position in the buffer TEF, and then executes step [5]. If not, executes step [7]. [5] The verification software APP determines whether all the N small segments split from the file EF have been received. If so, execute step [6]; if not, execute step [2]; [6] The verification software APP saves the ciphertext in the buffer TEF as a file EF, and then executes step [2]; [7] The verification software APP determines whether the QR code is an unblocking announcement based on the identification information. If so, it extracts the password DK and identification information and executes step [9]. Otherwise, it executes step [8]. [8] The verification software APP determines whether the QR code is a ban announcement based on the identification information. If so, it extracts the feature code MD and the identification information and then executes step [2]. If not, it executes step [2]. [9] The verification software APP uses the password DK to decrypt the file EF. If the decryption is successful, the image DP and the image YP are obtained and step
[10] is executed. Otherwise, step [2] is executed.
[10] The verification software APP verifies whether the feature code MD is the feature code of the image YP. If so, execute step
[11] ; otherwise, execute step [2].
[11] The verification software APP uses the image DP as seed data to generate the winning numbers according to the predetermined lottery algorithm, and then outputs the winning numbers, the image DP and the image YP to the display;
[12] If the verification software APP receives an exit signal, it ends; otherwise, it returns to step [2].
[0033] While the present invention has been shown and described with reference to certain preferred embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the following claims.< / cmath>
Claims
1. A lottery method that first seals and then unseals, and its working process is as follows: 【1】. Start the lottery software and initialize it; 【2】. Wait for several milliseconds. While waiting, read an image from the camera and output it to the display; 【3】. Determine whether it has reached the time point for sealing. If it has, execute step 【4】; otherwise, execute step 【2】; 【4】. Read a frame of image from the camera and randomly copy the image from this frame to obtain image DP; 【5】. Generate a sealing password DK, and then use this password to encrypt image DP using a predetermined encryption algorithm to generate file EF; 【6】. Split the ciphertext information in file EF into N small segments, add identification information to each split information segment, and output the small segments with added identification information one by one to the display in two forms: QR code and text. After all N small segments are displayed, execute the next step; 【7】. Wait for several milliseconds. While waiting, read an image from the camera and output it to the display; 【8】. Determine whether the confidentiality period has passed. If it has, execute step 【9】; otherwise, execute step 【7】; 【9】. Decrypt file EF with the sealing password DK to obtain image DP, generate unsealing announcement information using the identification information and the sealing password DK, then output the unsealing announcement information to the display in two forms: QR code and text, generate a winning number according to a predetermined lottery algorithm using image DP as seed data, and output the winning number and image DP to the display; 【10】. Output some information related to this lottery to the display, wait for a certain period of time, and then execute step 【2】.
2. The lottery method according to claim 1, characterized in that: Step 【5】 is modified to one of the following two: ① "【5】. Generate a sealing password DK using the data in image DP, and then use this password to encrypt image DP using a predetermined encryption algorithm to generate file EF;”; ② "【5】. Generate sealing announcement information using the identification information, output the sealing announcement information to the display in two forms: QR code and text, generate a sealing password DK using the data in image DP, and then use this password to encrypt image DP using a predetermined encryption algorithm to generate file EF;”.
3. A lottery method that first seals and then unseals, and its working process is as follows: 【1】. Start the lottery software and initialize it; 【2】. Wait for several milliseconds. While waiting, read an image from the camera and output it to the display; 【3】. Determine whether it has reached the time point for sealing. If it has, execute step 【4】; otherwise, execute step 【2】; 【4】. Read a frame of image from the camera and randomly copy the image from this frame to obtain image DP; [5] Copying image DP to obtain image YP identical to image DP, then using image DP as seed data to generate a lottery number according to a predetermined lottery algorithm and writing the lottery number into image YP, then calculating feature code MD of the data in image YP, and using identification information and feature code MD to generate account suspension announcement information, and outputting the account suspension announcement information to a display in the form of a QR code and text, and using the data in image DP and image YP to generate an account suspension password DK, and then using password DK to encrypt image DP and image YP using a predetermined encryption algorithm to generate file EF; [6] Divide the ciphertext information in the file EF into N small segments, add identification information to each of the divided information segments, and output the segments with identification information added to the display in the form of QR codes and text at a certain time interval. After all N small segments have been displayed, proceed to the next step. 【7】Wait for several milliseconds. While waiting, read the image from the camera and output it to the display; [8], determine whether the confidentiality period has expired. If so, proceed to step [9]; otherwise, proceed to step [7]; [9] Decrypt file EF with the blocking password DK to obtain image DP and image YP, then generate unblocking announcement information using identification information, blocking password DK and feature code MD, then output the unblocking announcement information to the display in the form of a QR code and text, and use image DP as seed data to generate a winning number according to a predetermined lottery algorithm, and output the winning number, image DP and image YP to the display; [10] Output some information related to the lottery to the display, wait for a while, and then execute step [2].
4. The lottery method according to claim 1 is characterized in that: Step [3] is modified to: "[3], determine whether a ban instruction has been received, if so, execute step [4], otherwise execute step [2];", And step [8] is modified to: "[8], determine whether an unblocking instruction has been received, if so, execute step [9], otherwise execute step [7];".
5. The lottery method according to claim 3 is characterized in that: Step [3] is modified to: "[3], determine whether a ban instruction has been received, if so, execute step [4], otherwise execute step [2];", And step [8] is modified to: "[8], determine whether an unblocking instruction has been received, if so, execute step [9], otherwise execute step [7];".
6. The lottery method according to claim 1 or 2 or 4, characterized in that: The winning numbers and image DP can be verified.
7. The lottery method according to claim 3 or 5, characterized in that: The winning numbers, image DP and image YP can be verified.
8. The lottery method according to claim 1 or 2 or 3 or 4 or 5, characterized in that: After the account sealing password DK is generated, the account sealing password DK is encrypted, and the password DK is decrypted before the decryption file EF.
9. The lottery method according to claim 6, characterized in that: After the account sealing password DK is generated, the account sealing password DK is encrypted, and the password DK is decrypted before the decryption file EF.
10. The lottery method according to claim 7, characterized in that: After the account sealing password DK is generated, the account sealing password DK is encrypted, and the password DK is decrypted before the decryption file EF.
