WO2014079282A1 - 存储和验证兑换码的方法和装置 - Google Patents

存储和验证兑换码的方法和装置 Download PDF

Info

Publication number
WO2014079282A1
WO2014079282A1 PCT/CN2013/084865 CN2013084865W WO2014079282A1 WO 2014079282 A1 WO2014079282 A1 WO 2014079282A1 CN 2013084865 W CN2013084865 W CN 2013084865W WO 2014079282 A1 WO2014079282 A1 WO 2014079282A1
Authority
WO
WIPO (PCT)
Prior art keywords
random value
redemption
redemption code
index
string
Prior art date
Application number
PCT/CN2013/084865
Other languages
English (en)
French (fr)
Inventor
周健
Original Assignee
腾讯科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Priority to US14/646,953 priority Critical patent/US9619657B2/en
Publication of WO2014079282A1 publication Critical patent/WO2014079282A1/zh
Priority to US15/453,280 priority patent/US10176304B2/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/901Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing
    • G06F16/90344Query processing by using string matching techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/02Marketing; Price estimation or determination; Fundraising
    • G06Q30/0207Discounts or incentives, e.g. coupons or rebates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/02Marketing; Price estimation or determination; Fundraising
    • G06Q30/0207Discounts or incentives, e.g. coupons or rebates
    • G06Q30/0225Avoiding frauds
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/10Protecting distributed programs or content, e.g. vending or licensing of copyrighted material ; Digital rights management [DRM]
    • G06F21/107License processing; Key processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/02Marketing; Price estimation or determination; Fundraising
    • G06Q30/0207Discounts or incentives, e.g. coupons or rebates
    • G06Q30/0239Online discounts or incentives

Definitions

  • Embodiments of the present invention relate to the field of information processing technologies, and more particularly, to a method and apparatus for storing and verifying a redemption code. Background of the invention
  • Redeem code also known as promo code or promotion code
  • the composition generally includes numbers and characters, such as YWERE77RMJA9. Users can use a redemption code to obtain a computer program or other various physical products. After the user redeems the program or other physical products, the redemption code generally fails.
  • a random algorithm is used to generate a plurality of character strings, the generated character string is used as a redemption code, and all redemption codes are completely stored in a storage space, such as a database.
  • the database is searched by means of string comparison to determine whether the verification code exists in the database or whether the verification code has been exchanged.
  • the randomly generated redemption code may also be repeated, so in the process of generating the redemption code or after the generation
  • the step of removing the duplicate generated redemption code results in inefficient generation of the redemption code.
  • a large amount of storage space is occupied. If the number of digits of the redemption code is reduced simply to save storage space, there is no guarantee that the success rate of the redemption code can be controlled.
  • a full-text comparison method is needed to find a database, a file or other storage medium, so the data retrieval amount is large and the verification efficiency is low.
  • Embodiments of the present invention provide a method and apparatus for storing and verifying a redemption code, thereby saving data storage space and improving verification efficiency of a redemption code in a situation where the success rate of the redemption code is controlled.
  • a method for storing a redemption code comprising:
  • a storage location of the random value is determined based on an index of the random value, and the random value is saved at the determined storage location.
  • a method for verifying a redemption code including:
  • Receiving a redemption code where the method for generating the redemption code includes:
  • a storage device for a redemption code comprising a random value generating unit, a redemption code generating unit and a redemption code storage unit, wherein:
  • the random value generating unit is configured to generate a random value, and determine an index of the random value according to a generating order of the random value;
  • the redemption code generating unit is configured to perform an index according to the random value and the random value Generating a pair of values, mapping the pair of values into a string, and generating a redemption code according to the string;
  • the redemption code storage unit is configured to determine a storage location of the random value according to an index of the random value, and save the random value at the determined storage location.
  • a verification device for a redemption code comprising a redemption code receiving unit, a storage location determining unit and a verification unit, wherein:
  • the redemption code receiving unit is configured to receive a redemption code, where the method for generating the redemption code includes:
  • the storage location determining unit is configured to obtain a character string according to the redemption code, inversely map the character string into a value pair, and determine a storage location according to an index of the random value in the value pair;
  • the verification unit is configured to further determine, when the random value stored at the storage location is not redeemed, whether the random value in the pair of values is consistent with a random value stored at the storage location, If yes, it is determined that the redemption code is verified successfully.
  • each redemption code is formed by a pair of numerical values by setting a redemption code into a mapping rule of a character string and a numerical value, wherein one value is a random value and the other value is It is an index related to the random value generation order.
  • the value pair is mapped into a string pair in the process of generating the redemption code, and only the random value needs to be stored when the redemption code is saved, so that the success rate of the redemption code can be controlled. In this case, you can also save data storage space.
  • the string pair is mapped into a numerical pair in the redemption link to verify the verification, thereby improving the verification efficiency of the redemption code.
  • the embodiments of the present invention can be applied to various terminals, and the present invention can be used across terminals according to platforms. The scope of application is very broad. BRIEF DESCRIPTION OF THE DRAWINGS
  • FIG. 1 is a flow chart of a method for storing a redemption code according to an embodiment of the present invention.
  • FIG. 2 is a flow chart of a method for verifying a redemption code according to an embodiment of the present invention.
  • FIG. 3 is a schematic diagram of a process of generating a redemption code according to an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of a verification process of a redemption code according to an embodiment of the present invention.
  • FIG. 5 is a structural diagram of a storage device of a redemption code according to an embodiment of the present invention.
  • FIG. 6 is a structural diagram of a verification apparatus of a redemption code according to an embodiment of the present invention. Mode for carrying out the invention
  • FIG. 1 is a flow chart of a method for storing a redemption code according to an embodiment of the present invention. As shown in Figure 1, the method includes the following steps.
  • Step 101 The server generates a random value, and determines an index of the random value according to the generation order of the random value.
  • various random number generation algorithms may be utilized to generate random values, and the index of the random values may be determined in accordance with the generation order of the random values.
  • the index of the random value is determined by the order in which the random values are generated. In one embodiment of the invention, the index is a positive integer that is continuously incremented.
  • the random number generation algorithm generates the random value 123 for the first time
  • the random number generation algorithm generates the random value 478 for the second time
  • the random number generation algorithm generates the random value 567 for the third time
  • the random value can be determined.
  • the index of 123 is 1, the index of the random value 478 is 2, and the index of the random value 567 is 3.
  • Step 102 The server arranges the random value and the index of the random value into a value pair.
  • the value pair is mapped to a string, which can be used as a redemption code.
  • the confusing operation may be further performed on the mapped character string, and the character string after the confusing operation is performed as the redemption code.
  • the random value generated in step 101 and the index of the random value are first arranged into a pair of values, and then the pair of values is mapped into a character string, and the pair of strings is confused to form a redemption code.
  • the value pairs may be first mapped into a string pair in a plurality of ways.
  • One implementation is to use a numeric-to-string function ( num 2str ) to convert each value in the pair of values to a corresponding 24-character string, thereby mapping the value pairs to string pairs.
  • a new string is formed, and the new string is used as the verification code, and the character string (such as the 24-character string) can be further ) Confusion to enhance security.
  • the obfuscation operation is a program conversion technique that can be used to protect mobile code and software intellectual property.
  • the embodiments of the present invention can employ various existing obfuscation algorithms, or use confusion algorithms that may occur in the future.
  • the values 0-23 in the process of converting the pair of values into a string, can be mapped to 24 characters, for example: "0", “1", "2",
  • the confusion is "6C43G4BG60" as a redemption code waiting for storage.
  • step 101 suppose that in step 101, the 100000th random value is 47982341, then the value pair is (100000, 47892341), and the data value pair is represented by the corresponding 24-digit ("75EG", "608AA5"). Map the string to "75EG608AA5".
  • Y is the 24 characters in the 24-digit conversion.
  • embodiments of the present invention are not limited to hexadecimal, but are applicable to any radix and mapping algorithm.
  • Step 103 The server determines a storage location of the random value according to the index of the random value, and saves the random value at the determined storage location.
  • the correspondence between the index and the storage location is saved in a redemption index table.
  • a bitmap, a hash, or an array may be used to determine, according to the index of the random value, the corresponding storage location of the random value in the redemption index table, and The random value is saved at the determined storage location.
  • the redemption status bit corresponding to the random value is further stored in the redemption index table, and is used to indicate the redemption status of the redemption code corresponding to the random value, that is, whether the redemption code has been Was exchanged.
  • a plurality of bits may be used to indicate the redemption status of the redemption code, which is not limited in the embodiment of the present invention.
  • the random value 22078136 may be stored in the storage location corresponding to the index 50000 in the redemption index table; the 900000th random value is 33069592, and the index corresponding to the index 90000 in the redemption index table may be The storage location stores the random value 33069592; the 100000th random value is 47982341, and the random value 47982341 can be stored in the storage location corresponding to the index 10000 in the redemption index table.
  • the expected number of generations of the redemption code may be determined in advance, and the number of digits of the index is determined according to the expected number of generations of the redemption code; and the redemption code crack probability threshold is determined, and The redemption code crack probability threshold determines the number of bits of the random value.
  • the random value is generated in step 101 and the order is determined according to the generation order of the random value.
  • the index of the random value includes: generating a random value according to the number of bits of the random value, and determining an index of the random value according to the generation order of the random value and the number of bits of the index.
  • a redemption code with a planned number of 4 billion and a crack success probability of less than 796 million is used as an example.
  • each character of the index value and the random value can represent a 24-value value, so that the meaning of a character representation can be separated, one part represents an index value, and a part represents a random value, for example, the first 20-20 bits represent a random value.
  • the 21-24bit represents the index value.
  • a bitmap, a hash, or an array may be used to place the exchange index table in the memory to speed up the search.
  • the embodiment of the invention also proposes a verification method of the redemption code.
  • FIG. 2 is a flow chart of a method for verifying a redemption code according to an embodiment of the present invention. As shown in Figure 2, the method includes the following steps.
  • Step 201 The server receives the redemption code, where the method for generating the redemption code includes: generating a random value, and determining an index of the random value according to the generation order of the random value; arranging the random value and the index of the random value into A pair of values, maps the pair of values into a string, and confuses the pair of strings to form a redemption code.
  • the received redemption code may be a redemption code generated according to the method shown in FIG.
  • Step 202 Perform an anti-aliasing operation on the redemption code, obtain a character string corresponding to the redemption code, and further determine a string pair corresponding to the redemption code, and inversely map the string pair to a value pair, and according to the value The index of the random value in the pair determines the storage location.
  • Step 203 When the server determines that the random value stored at the storage location is not redeemed, further determining whether the random value in the pair of values is consistent with the random value stored at the storage location, and if so, Then it is determined that the redemption code is verified successfully.
  • this step it may be determined according to the redemption status bit in the redemption index table whether the random value stored at the storage location has been redeemed. When it is judged that the random value stored at the storage location has been redeemed, it is determined that the redemption code has been redeemed before, and thus the verification fails. When it is determined that the random value stored in the storage location is not redeemed, it is determined that the redemption code has not been redeemed before, further querying the redemption index table, and determining whether the random value obtained in step 202 is in the redemption index table Whether the random values stored in the storage location are consistent.
  • step 202 If the random value obtained in step 202 is consistent with the random value stored in the storage location in the redemption index table, it is determined that the redemption code verification is successful, if the random value obtained in step 202 is If the random values stored in the storage location in the redemption index table are inconsistent, it is determined that the redemption code verification fails.
  • the redemption status bit corresponding to the random value in the redemption index table is updated to be redeemed.
  • the generation efficiency and verification efficiency of the redemption code are improved, and the storage and verification process of the redemption code is completely free from the database, and the redemption code is stored and inquired according to the index, and the success rate of the redemption code is controllable.
  • FIG. 3 is a schematic diagram of a process of generating a redemption code according to an embodiment of the present invention.
  • 4 is a schematic diagram of a verification process of a redemption code according to an embodiment of the present invention.
  • a description is made by taking an example of generating 4 billion redemption codes.
  • 4 billion random values with a value range of [0, 7962624) are generated in sequence. And keep a comparison of the index and the random value in the redemption index table for use in the subsequent redemption phase. Then the index value ( inputjdx ) and the random value ( input_random ) are converted into 4 billion strings by the function num2str of the value to the string ( string ), and then the 4 billion strings are passed through a certain confusion algorithm, such as exchange The order is combined into 4 billion redemption codes and provided to customers for use. At the same time, the random value is stored in the storage location corresponding to the index.
  • the redemption code is first restored to a pair of strings by an anti-aliasing operation, and the pair of strings is converted into a value pair by a string-to-value function str2num, where the index value is input_idx, The random value is input_random, and then the redemption index table is searched according to input_idx.
  • the redemption index table can be bitmap or hash or data. The table of the library determines whether the redemption code has been redeemed.
  • the redemption code has not been redeemed, find the random value corresponding to inputjdx in the redemption index table, compare the found random value with input-random , a random value if found and the same input-random, shellfish 1 J is determined redemption code authentication is successful, the exchange and updating the corresponding redemption code redemption status bit index table; and a random value if found different input_random , then it is determined that the redemption code 3 fails.
  • the embodiment of the invention also proposes a storage device for the redemption code.
  • FIG. 5 is a structural diagram of a storage device of a redemption code according to an embodiment of the present invention. As shown in FIG. 5, the apparatus includes a random value generating unit 501, a redemption code generating unit 502, and a redemption code storage unit 503.
  • the random value generating unit 501 is configured to generate a random value, and determine an index of the random value in accordance with the generation order of the random value.
  • the redemption code generating unit 502 is configured to arrange the random value and the index of the random value into a value pair, and map the value pair into a character string to form a redemption code.
  • the redemption code storage unit 503 is configured to determine a storage location of the random value based on the index of the random value, and save the random value at the determined storage location.
  • the apparatus further includes a bit number determining unit 504.
  • the digit determining unit 504 is configured to determine the number of redemption codes, and determine the number of bits of the index according to the number of redemption codes; determine a redemption code crack probability threshold, and determine according to the redemption code crack probability threshold The number of random values.
  • the random value generating unit 501 is configured to generate a random value according to the number of bits of the random value, and determine an index of the random value according to the generation order of the random value and the number of bits of the index.
  • the redemption code storage unit 502 is configured to use a bitmap, a hash, or an array according to the random value. Determining the storage location of the random value in the redemption index table, and storing the random value at the storage location in the determined redemption index table, and saving in the redemption index table indicates whether the random value has been redeemed. The redemption status bit is further used to update the redemption status bit status of the random value at the storage location in the redemption index table to be redeemed when it is determined that the redemption code verification is successful.
  • the embodiment of the invention also proposes a verification device for the redemption code.
  • FIG. 6 is a structural diagram of a verification apparatus of a redemption code according to an embodiment of the present invention. As shown in Fig. 6, the apparatus includes a redemption code receiving unit 601, a storage location determining unit 602, and a verification unit 603.
  • the redemption code receiving unit 601 is configured to receive a redemption code, where the method for generating the redemption code includes: generating a random value, and determining an index of the random value according to a generation order of the random value; the random value and the random The index of values is arranged into a pair of values, the pair of values is mapped into a pair of strings, and the pair of strings is confused to form a redemption code.
  • the storage location determining unit 602 is configured to perform an anti-aliasing operation on the redemption code, obtain a character string corresponding to the redemption code, and inversely map the character string into a value pair, and according to the random number in the value pair The index of the value determines the storage location.
  • a verification unit 603 configured to: when determining that the random value stored at the storage location is not redeemed, further determining whether the random value in the pair of values is consistent with the random value stored at the storage location, if Yes, it is determined that the redemption code is verified successfully.
  • the verification unit 603 determines whether the random value stored at the storage location has been redeemed, and if the random value stored at the storage location has been redeemed, determining the redemption code Verification failure; if the random value stored at the storage location is not redeemed, further determining whether the random value in the pair of values is consistent with the random value stored at the storage location, if the value is aligned The random value is consistent with the random value stored at the storage location, and then the redemption code verification is successful, if the number is If the random value in the value pair does not coincide with the random value stored at the storage location, it is determined that the redemption code verification fails.
  • the verification unit 603 is configured to determine, according to the redemption status bit in the redemption index table, whether the random value stored at the storage location has been redeemed, and update the redemption when it is determined that the redemption code verification is successful.
  • the redemption status bit of the random value at the storage location in the index table is redeemed.
  • the method flow shown in Fig. 1 and Fig. 2 and the device structure shown in Fig. 5 and Fig. 6 can be integrated into various forms of hardware entities as servers. For example, it can be integrated into: feature phones, smartphones, PDAs, personal computers (PCs), tablets or personal digital assistants (PDAs), and more.
  • the methods and apparatus provided by the embodiments of the present invention may be implemented by hardware, or computer readable instructions, or a combination of hardware and computer readable instructions.
  • the computer readable instructions used in this embodiment are stored by a plurality of processors in a readable storage medium, such as a hard disk,
  • CD-ROM compact disc-read only memory
  • DVD digital versatile disc
  • CD compact disc-read only memory
  • floppy disk CD-ROM
  • tape hard disk
  • RAM hard disk
  • ROM read only memory
  • computer readable instructions may be replaced by specific hardware, such as custom integrated circuits, gate arrays, FPGAs, PLDs, and computers with specific functions, and the like.
  • Embodiments of the present invention provide a computer readable storage medium for storing instructions for causing a computer to perform the methods described herein.
  • the system or device provided by this embodiment has a storage medium in which computer readable program code is stored for implementing the functions of any of the above embodiments, and these systems or devices (or CPUs or MPUs) can read and Execute the program code stored on the storage medium.
  • the program code read from the storage medium can implement any of the above embodiments, and thus the program code and the storage medium storing the program code are part of the technical solution.
  • the storage medium for providing the program code includes a floppy disk, a hard disk, a magneto-optical disk, and an optical disk (for example) Such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), disk, flash card, ROM, etc.
  • the program code can also be downloaded from a server computer over a communication network.
  • an operation at least partially implemented by the program code may be implemented by an operating system running on a computer, thereby implementing the technical solution of any of the above embodiments, wherein the computer is executed based on the program code. instruction.
  • program code in the storage medium is written to the memory, wherein the memory is located in an expansion board inserted in the computer or in an expansion unit connected to the computer.
  • the CPU in the expansion board or the expansion unit performs at least part of the operation based on the program code according to the instruction, thereby implementing the technical solution of any of the above embodiments.
  • a computer file running device can be written as a plug-in installed in a computer system by following a certain specification application interface, or it can be packaged as an application for the user to download and use.
  • a plug-in it can be implemented as a variety of plug-ins such as ocx, dll, and cab.
  • the storage and/or verification device of the redemption code proposed by the embodiment of the present invention may also be implemented by a specific technology such as a Flash plug-in, a RealPlayer plug-in, an MMS plug-in, a MIDI staff plug-in, or an ActiveX plug-in.
  • each redemption code is composed of a pair of values, one of which is a random value, and the other is a Random values are generated in order-dependent indexes.
  • the value pairs are mapped into a character string, and only the random value needs to be stored when the redemption code is saved, so that the data storage space can be saved while ensuring that the success rate of the redemption code is controllable.
  • the string is mapped to a numerical value in the redemption link. Line verification, thereby improving the verification efficiency of the redemption code.
  • embodiments of the present invention can be applied to various terminals, and the embodiments of the present invention can be used across terminals according to the platform, and the scope of application is very wide.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Accounting & Taxation (AREA)
  • Development Economics (AREA)
  • Finance (AREA)
  • Strategic Management (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Entrepreneurship & Innovation (AREA)
  • General Business, Economics & Management (AREA)
  • Marketing (AREA)
  • Economics (AREA)
  • Game Theory and Decision Science (AREA)
  • Computational Linguistics (AREA)
  • Computer Hardware Design (AREA)
  • Computer Security & Cryptography (AREA)
  • Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Treatment And Welfare Office Work (AREA)
  • Storage Device Security (AREA)
  • Multimedia (AREA)
  • Technology Law (AREA)

Abstract

一种兑换码的存储、验证的方法和装置。方法包括:生成随机值,按照随机值的生成顺序确定随机值的索引;根据随机值和随机值的索引生成数值对,将数值对映射成字符串,根据字符串生成兑换码;根据随机值的索引确定随机值的存储位置,并在所确定的存储位置保存随机值。

Description

存储和 兑换码的方法和装置
技术领域
本发明实施方式涉及信息处理技术领域, 更具体地, 涉及一种存储 和验证兌换码的方法和装置。 发明背景
兌换码 ( Redeem code ) , 又叫推广码 ( promo code 或 promotion code ) , 一般是开发者用来推广实际产品或计算机程序产品的代码, 其 构成一般包括数字和字符等, 例如: YWERE77RMJA9。 用户可以使用 兌换码获得计算机程序或者其他各种实体产品。 在用户兌换完程序或 者其他实体产品之后, 兌换码一般就失效。
根据现有的兌换码生成和存储方式, 采用随机算法生成若干个字符 串, 将该生成的字符串作为兌换码, 并且将所有兌换码都完整地保存 在存储空间, 如数据库中。 相应地, 在验证兌换码时, 通过字符串比 较的方式来查找数据库, 从而确定数据库中是否存在该验证码或确定 该验证码是否已经兌出。
然而, 根据现有的兌换码的生成方式, 在兌换码的数量非常巨大的 情况下, 随机生成的兌换码也可能重复, 所以在生成兌换码的过程中 或生成后还需要有去除重复生成的兌换码的步骤从而造成兌换码的生 成效率低下。 而且, 由于全部兌换码完整地保存在数据库, 大量的存 储空间被占用。 如果单纯为了节约存储空间而降低兌换码的位数, 则 无法保证兌换码的破解成功率可控。 进一步地, 根据现有的兌换码的 验证方式, 需要采用全文对比的方式查找数据库、 文件或其他存储介 质, 因此数据检索量大, 验证效率低下。 发明内容
本发明实施方式提出一种存储和验证兌换码的方法和装置, 从而在 保证兌换码的破解成功率可控的情形下, 节约数据存储空间, 提高兌 换码的验证效率。
一种兌换码的存储方法, 包括:
生成随机值,并按照所述随机值的生成顺序确定所述随机值的索引; 根据所述随机值以及所述随机值的索引生成数值对, 将所述数值对 映射成字符串, 根据所述字符串生成兌换码;
根据所述随机值的索引确定所述随机值的存储位置, 并在所确定的 存储位置处保存所述随机值。
一种兌换码的验证方法, 包括:
接收兌换码, 其中所述兌换码的生成方法包括:
生成随机值,并按照所述随机值的生成顺序确定所述随机值的索引; 根据所述随机值以及所述随机值的索引生成数值对, 将所述数值对映射 成字符串, 根据所述字符串生成所述兌换码;
根据兌换码获取字符串, 将所述字符串反映射为数值对, 并按照所 述数值对中的随机值的索引确定存储位置;
当判定所述存储位置处储存的随机值没有被兌换时, 进一步判断所 述数值对中的所述随机值与在所述存储位置处储存的所述随机值是否 一致, 如果是, 则判定兌换码验证成功。
一种兌换码的存储装置, 该装置包括随机值生成单元、 兌换码生成 单元和兌换码存储单元, 其中:
所述随机值生成单元, 用于生成随机值, 并按照所述随机值的生成 顺序确定所述随机值的索引;
所述兌换码生成单元, 用于根据所述随机值以及所述随机值的索引 生成数值对, 将所述数值对映射成字符串, 根据所述字符串生成兌换 码;
所述兌换码存储单元, 用于根据所述随机值的索引确定所述随机值 的存储位置, 并在所确定的存储位置处保存所述随机值。
一种兌换码的验证装置, 包括兌换码接收单元、 存储位置确定单元 和验证单元, 其中:
所述兌换码接收单元, 用于接收兌换码, 其中该兌换码的生成方法 包括:
生成随机值, 并按照所述随机值的生成顺序确定所述随机值的索 对映射成字符串, 根据所述字符串生成所述兌换码;
所述存储位置确定单元, 用于根据所述兌换码获取字符串, 将所述 字符串反映射为数值对, 并按照所述数值对中的随机值的索引确定存 储位置;
所述验证单元, 用于当判定所述存储位置处储存的随机值没有被兌 换时, 进一步判断所述数值对中的所述随机值与在所述存储位置处储 存的随机值是否一致, 如果是, 则判定兌换码验证成功。
从上述技术方案可以看出, 根据本发明实施方式, 通过把兌换码设 置成字符串与数值的映射规则, 每个兌换码由一对数值构成, 其中一 个数值是随机值, 另一个数值是与随机值生成顺序相关的索引, 在生 成兌换码环节把数值对映射成字符串对, 而且在保存兌换码时只需要 存储随机值, 因此在保证兌换码的破解成功率可控的情形下, 还可以 节约数据存储空间。 而且, 在本发明实施方式中, 在兌换环节把字符 串对映射成数值对进行验证, 从而提高兌换码的验证效率。 另外, 本 发明实施方式可以应用到各种终端中, 可以跨平台跨终端使用本发明 实施方式, 适用范围非常广泛。 附图简要说明
图 1为根据本发明实施方式的兌换码的存储方法流程图。
图 2为根据本发明实施方式的兌换码的验证方法流程图。
图 3为根据本发明实施方式的兌换码的生成过程示意图。
图 4为根据本发明实施方式的兌换码的验证过程示意图。
图 5为根据本发明实施方式的兌换码的存储装置结构图。
图 6为根据本发明实施方式的兌换码的验证装置结构图。 实施本发明的方式
为使本发明的技术方案和优点更加清楚, 下面结合附图对本发明作 进一步的详细描述。
图 1为根据本发明实施方式的兌换码的存储方法流程图。 如图 1所 示, 该方法包括如下步骤。
步骤 101 : 服务器生成随机值, 并按照该随机值的生成顺序确定该 随机值的索引。
在本步骤中, 可以利用各种随机数生成算法来生成随机值, 而且可 以按照该随机值的生成顺序确定该随机值的索引。
随机值的索引是由随机值的生成顺序所确定。 在本发明的一个实施 例中, 该索引是连续递增的正整数。 比如, 应用随机数生成算法第一 次生成了随机值 123 , 应用随机数生成算法第二次生成了随机值 478, 应用随机数生成算法第三次生成了随机值 567 , 则可以确定该随机值 123的索引为 1、 随机值 478的索引为 2, 随机值 567的索引为 3。
步骤 102: 服务器将该随机值以及该随机值的索引排列成数值对, 将该数值对映射成字符串, 此时可以利用该字符串作为兌换码。
在本发明的一个实施例中, 还可以进一步对映射出的字符串执行混 淆操作, 并将执行混淆操作后的字符串作为兌换码。
在本步骤中, 首先将在步骤 101中生成的随机值以及该随机值的索 引排列成数值对, 然后再将该数值对映射成字符串, 并且混淆字符串 对以形成兌换码。
本发明实施方式中, 可以首先通过多种方式来将数值对映射成字符 串对。 其中一种实现方式是, 利用数值到字符串函数(num2str ) , 将该 数值对中的每个数值转换为对应的 24 进制的字符串, 从而将数值对映 射为字符串对。 之后根据索引值和随机值这两个数值对应的两个字符 串组成一个新字符串, 以这个新字符串作为验证码, 进一步的可以对 所述字符串 (如所述 24进制的字符串 )进行混淆以加强安全性。 混淆 操作是一种可以用于对移动代码和软件知识产权进行保护的程序变换 技术, 本发明实施方式可以采用各种现有的混淆算法, 或者采用将来 可能出现的混淆算法。
在本发明的一个实施例中, 在该数值对转化为字符串的过程中, 可 以分别将数值 0-23映射为 24个字符, 比如: "0" 、 "1" 、 "2" 、
"3 " 、 "4" 、 "5 " 、 "6" 、 "7" 、 " 8" 、 "9" 、 "A" 、
"B" 、 "C" 、 "D" 、 "E" 、 "F" 、 "G" 、 "H" 、 "I" 、
"J" 、 "K" 、 "L" 、 "M" 、 "N" 。
假如在步骤 101中第 50000个随机值是 22078136, 那么该数值对就 是 (50000,22078136), 该数据值对对应的 24 进制表示为 ( "3EJ8" ,
"2ID228" ) , 此时映射出字符串为 "3EJ82ID228" 。
然后, 可以利用各种混淆算法, 对该映射出字符串进行混淆。 比 如, 混淆为 "3E2ID228J8" 以作为等待存储的兌换码。 再比如, 假设在步骤 101中第 90000个随机值是 33069592, 那么该 数值对就是 (90000, 33069592) , 该数据值对对应的 24 进制表示为 ( " 6C60 " , " 43G4BG " ) , 此 时 映射 出 字 符 串 为 "6C6043G4BG" 。
然后, 可以利用各种混淆算法, 对该映射出字符串进行混淆。 比 如, 混淆为 "6C43G4BG60" 以作为等待存储的兌换码。
再比如, 假设在步骤 101 中第 100000个随机值是 47892341 , 那么 该数值对就是 (100000, 47892341), 该数据值对对应的 24 进制表示为 ( " 75EG " , " 608AA5 " ) , 此 时 映射 出 字符 串 为 "75EG608AA5" 。
然后, 可以利用各种混淆算法, 对该映射出字符串进行混淆。 比 如, 混淆为 "75608AA5EG以作为等待存储的兌换码。
在本发明的一个实施例中, 由于在 "0" 、 "1" 、 "2" 、 "3" 、 "4" 、 "5 " 、 "6" 、 "7" 、 " 8" 、 "9" 、 "A" 、 "B " 、 "C" 、 "D" 、 "E" 、 "F" 、 "G" 、 "H" 、 "I" 、 "J" 、 "K" 、 "L" 、 "M" 、 "N" 字符中, 会有一些视觉类似的字符。 因 此, 优选采用 "3" 、 "4" 、 "5" 、 "6" 、 "7" , . "9" 、 "A"
" c ,, " E ,, "F" 、 "G" 、 "H" 、 "J" 、 "K" 、 "L"
"M" 、 "N" 、 "P" 、 "R" 、 "S" 、 "T" 、 "W" 、 "X"
"Y" 作为 24进制转换中的 24个字符。 领域技术人员可以意识到, 本发明实施方式并不局限于 24进制, 而是 适用于任意的进制以及映射算法。
步骤 103: 服务器根据该随机值的索引确定该随机值的存储位置, 并在所确定的存储位置处保存该随机值。 在本发明的一个实施例中, 将索引与存储位置的对应关系保存在兌 换索引表中。
在本步骤中, 可以利用位图( bitmap )、 哈希( hash )或数组( array ) 的方式, 根据该随机值的索引确定该随机值在兌换索引表中对应的存 储位置, 并在所确定的存储位置处保存该随机值。
在本发明的一个实施例中, 进一步在兌换索引表中保存与随机值对 应的兌换状态位, 用于指示该随机值对应的兌换码的兌换状态, 即该 兌换码是否已被兌换。
比如: 可以用 1 个比特(bit )作为兌换状态位, 这样存储容量为 1Mbyte的内存就可以存储 800万个兌换码的兌换状态。
当兌换码较多的时候, 还可以用多个比特来表示兌换码的兌换状 况, 本发明实施方式对此并无限定。
比如, 第 50000个随机值是 22078136, 则可以在兌换索引表中索引 50000对应的存储位置存储该随机值 22078136; 第 90000 个随机值是 33069592, 则可以在兌换索引表中索引 90000对应的存储位置存储该随 机值 33069592; 第 100000个随机值是 47892341 , 则可以在兌换索引表 中索引 10000对应的存储位置存储该随机值 47892341。
在实际应用中, 无需存储随机值的索引, 只需要能够根据索引值确 定随机值的存储位置即可。 譬如到数组的 50000 位置存储 22078136 ( array[5000]=22078136 )。
在本发明的一个实施例中, 还可以预先确定兌换码的期望生成数 目, 并根据兌换码的期望生成数目确定索引的位数; 再确定兌换码破 解概率门限值, 并根据所述兌换码破解概率门限值确定随机值的位 数。
此时, 步骤 101中的生成随机值并按照该随机值的生成顺序确定该 随机值的索引包括: 按照该随机值的位数生成随机值, 并且按照该随 机值的生成顺序和索引的位数确定该随机值的索引。
以期望生成数量为 40亿、 破解成功概率小于 796万分之 1的兌换码 为例进行说明。
由于 24Λ7=4586471424, 其值域超过 45亿, 因此索引值可以占用 7 个字符。 由于 24Λ5=7962624, 其值域超过 796万, 因此随机值可以占用 5个字符。 因此, 兌换码共 12个字符( 12=7+5 ) , 则可以生成 45亿个 兌换码, 而且破解的成功概率小于 796万分之 1。
如果要进一步降低破解的成功率, 可以增加随机值的字符个数。 比 如: 当随机值有 6位的话, 破解成功率就小于 1亿 9000万分之 1 , 兌换 码一共为 13个字符。
在上述实施例提供的方法中, 通过把索引值和随机值生成的字符串 进行混淆, 使得普通用户更难从中发现规律。 而且索引值和随机值每 个字符都可以表示一个 24进制的值, 因此可以将一个字符表示的含义 拆开, 其中一部分表示索引值, 一部分表示随机值, 比如第 l—20bit表 示随机值, 第 21-24bit表示索引值。 而且, 在验证兌换码的过程中, 还 可以采用位图 (bitmap ) 、 哈希 (hash )或数组(array ) 的方式, 将兌 换索引表全部放在内存中加快查找的效率。
本发明实施方式还提出了一种兌换码的验证方法。
图 2为根据本发明实施方式的兌换码的验证方法流程图。 如图 2所 示, 该方法包括如下步骤。
步骤 201 : 服务器接收兌换码, 其中该兌换码的生成方法包括: 生 成随机值, 并按照该随机值的生成顺序确定该随机值的索引; 将该随 机值以及该随机值的索引排列成数值对, 将该数值对映射成字符串, 并且混淆所述字符串对以形成兌换码。 在本步骤中, 所接收的兌换码可以是根据图 1所示方法生成的兌换 码。
步骤 202: 对该兌换码执行反混淆操作, 获取该兌换码对应的字符 串, 进而确定兌换码对应的字符串对, 将所述字符串对反映射为数值 对, 并按照该数值对中的该随机值的索引确定存储位置。
首先, 针对该兌换码执行与兌换码生成过程中的混淆操作相逆的反 混淆操作, 从而得到该兌换码对应的原始字符串, 将原始字符串拆解 为字符串对, 然后再将所述字符串对执行与兌换码生成过程中的映射 操作相逆的反映射操作, 从而将该字符串对还原为数值对, 该数值对 包括随机值以及随机值的索引, 再按照该数值对中的该随机值的索引 确定该兌换码的存储位置。
步骤 203: 当服务器判定所述存储位置处储存的该随机值没有被兌 换时, 进一步判断该数值对中的该随机值与在所述存储位置处储存的 该随机值是否一致, 如果是, 则判定兌换码验证成功。
在本发明的一个实施例中, 可以首先判断所述存储位置处储存的该 随机值是否已经兌换, 如果所述存储位置处储存的该随机值已经被兌 换, 则判定兌换码验证失败; 如果所述存储位置处储存的该随机值未 被兌换, 则进一步判断该数值对中的该随机值与在所述存储位置处储 存的该随机值是否一致, 如果该数值对中的该随机值与在所述存储位 置处储存的该随机值一致, 则判定兌换码验证成功, 如果该数值对中 的该随机值与在所述存储位置处储存的该随机值不一致, 则判定兌换 码验证失败。
在本步骤中, 可以根据兌换索引表中的兌换状态位来判定存储位置 处储存的该随机值是否已经兌换。 当判断所述存储位置处储存的该随 机值已经兌换时, 则判定兌换码之前已经兌现过, 因此验证失败。 当判断所述存储位置处储存的该随机值没有兌换时 , 则判定兌换码 之前没有兌现过, 进一步查询兌换索引表, 判断步骤 202中获得的随机 值是否与兌换索引表中存储位置处储存的随机值是否一致, 如果步骤 202 中获得的随机值与兌换索引表中存储位置处储存的随机值一致, 判 定兌换码验证成功, 如果步骤 202中获得的随机值是否与兌换索引表中 存储位置处储存的随机值不一致, 则判定兌换码验证失败。
在本发明的一个实施例中, 在该方法中, 进一步当判定兌换码验证 成功时, 更新兌换索引表中该随机值对应的兌换状态位为已兌换。
通过应用本发明实施方式, 提高了兌换码的生成效率和验证效率, 并且兌换码的存储和验证过程完全摆脱数据库, 根据索引存储和查询 兌换码, 而且兌换码破解的成功率是可控的。
图 3为根据本发明实施方式的兌换码的生成过程示意图。 图 4为根 据本发明实施方式的兌换码的验证过程示意图。
根据本发明的一个实施例, 以生成 40亿个兌换码为例进行说明。 在兌换码的生成和存储过程中, 首先顺序生成 40 亿个值域为 [0, 7962624)的随机值。 并保留一份索引与随机值的对照关系在兌换索引表 中以备后续兌换阶段使用。 然后把索引值 ( inputjdx ) 和随机值 ( input—random )通过数值到字符串 ( string ) 的函数 num2str转化为 40 亿个字符串, 再把这 40亿个字符串通过一定的混淆算法, 譬如调换次 序组合成 40亿个兌换码, 并提供给客户进行使用。 同时将随机值存储 在索引对应的存储位置。
在验证兌换码的过程中, 首先把兌换码通过反混淆操作还原为一对 字符串, 再把这对字符串通过字符串到数值的函数 str2num转化为数值 对, 其中索引值是 input_idx, 随机值是 input_random, 再根据 input_idx 查找兌换索引表, 该兌换索引表可以是 bitmap也可以是 hash或者数据 库的表, 确定该兌换码是否已经兌换过了, 如果该兌换码没有兌换 过, 则找到在兌换索引表中与 inputjdx对应的随机值, 比较找到的随 机值和 input—random, 如果找到的随机值和 input—random相同, 贝1 J确定 兌换码验证成功, 并且在兌换索引表中更新该兌换码对应的兌换状态 位; 如果找到的随机值和 input_random 不相同, 则确定兌换码 3全证失 败。
本发明实施方式提供的方法可以在各种形式的服务器中实施。
本发明实施方式还提出了一种兌换码的存储装置。
图 5为根据本发明实施方式的兌换码的存储装置结构图。 如图 5所 示, 该装置包括随机值生成单元 501、 兌换码生成单元 502和兌换码存 储单元 503。
随机值生成单元 501用于生成随机值, 并按照该随机值的生成顺序 确定该随机值的索引。
兌换码生成单元 502用于将该随机值以及该随机值的索引排列成数 值对, 将该数值对映射成字符串, 以形成兌换码。
兌换码存储单元 503用于根据该随机值的索引确定该随机值的存储 位置, 并在所确定的存储位置处保存所述随机值。
在一个实施方式中, 该装置进一步包括位数确定单元 504。
位数确定单元 504用于确定兌换码的数目, 并根据兌换码的数目确 定索引的位数; 确定兌换码破解概率门限值, 并根据所述兌换码破解 概率门限值确定随机值的位数。
随机值生成单元 501用于按照该随机值的位数生成随机值, 并且按 照该随机值的生成顺序和索引的位数确定该随机值的索引。
根据本发明一个实施例, 兌换码存储单元 502 用于以位图 ( bitmap ) 、 哈希 (hash )或数组(array ) 的方式, 根据该随机值的索 引确定该随机值在兌换索引表中的存储位置, 并在所确定的兌换索引 表中的存储位置处保存该随机值, 而且在兌换索引表中保存表明该随 机值是否已兌换的兌换状态位; 并进一步用于当判定兌换码验证成功 时, 更新兌换索引表中该存储位置处随机值的兌换状态位状态为已兌 换。
本发明实施方式还提出了一种兌换码的验证装置。
图 6为根据本发明实施方式的兌换码的验证装置结构图。 如图 6所 示, 该装置包括兌换码接收单元 601、 存储位置确定单元 602和验证单 元 603。
兌换码接收单元 601 , 用于接收兌换码, 其中该兌换码的生成方法 包括: 生成随机值, 并按照该随机值的生成顺序确定该随机值的索 引; 将该随机值以及该随机值的索引排列成数值对, 将该数值对映射 成字符串对, 并且混淆所述字符串对以形成兌换码。
存储位置确定单元 602, 用于对所述兌换码执行反混淆操作, 获取 该兌换码对应的字符串, 并将所述字符串反映射为数值对, 并按照该 数值对中的该随机值的索引确定存储位置。
验证单元 603 , 用于当判定所述存储位置处储存的该随机值没有被 兌换时, 进一步判断该数值对中的该随机值与在所述存储位置处储存 的该随机值是否一致, 如果是, 则判定兌换码验证成功。
在本发明的一个实施例中, 验证单元 603 , 判断所述存储位置处储 存的该随机值是否已经兌换, 如果所述存储位置处储存的该随机值已 经被兌换, 则判定兌换码验证失败; 如果所述存储位置处储存的该随 机值未被兌换, 则进一步判断该数值对中的该随机值与在所述存储位 置处储存的该随机值是否一致, 如果该数值对中的该随机值与在所述 存储位置处储存的该随机值一致, 则判定兌换码验证成功, 如果该数 值对中的该随机值与在所述存储位置处储存的该随机值不一致, 则判 定兌换码验证失败。
在一个实施方式中, 验证单元 603用于根据兌换索引表中的兌换状 态位来判定存储位置处储存的该随机值是否已经兌换, 并当判定兌换 码验证成功时, 更新兌换索引表中该存储位置处随机值的兌换状态位 为已兌换。
图 1、 图 2所示方法流程和图 5、 图 6所示装置结构可以集成到各种 形式的作为服务器的硬件实体当中。 比如, 可以集成到: 功能手机、 智能手机、 掌上电脑、 个人电脑 (PC ) 、 平板电脑或个人数字助理 ( PDA ) , 等等设备之中。
本发明实施例提供的方法和装置可以由硬件、 或计算机可读指令、 或者硬件和计算机可读指令的结合来实现。 本实施例中使用的计算机 可读指令由多个处理器存储在可读存储介质中, 例如硬盘、
CD-ROM, DVD, 光盘、 软盘、 磁带、 RAM、 ROM或其它合适的存储 设备。 或者, 至少部分计算机可读指令可以由具体硬件替换, 例如, 定制集成线路、 门阵列、 FPGA、 PLD和具体功能的计算机等等。
本发明实施例提供了计算机可读存储介质, 用于存储指令使得计算 机执行本文所述的方法。 具体地, 本实施例提供的***或设备都具有 存储介质, 其中存储了计算机可读程序代码, 用于实现上述任意实施 例的功能, 并且这些***或设备(或 CPU或 MPU ) 能够读取并且执行 存储在存储介质中的程序代码。
在这种情况下, 从存储介质中读取的程序代码可以实现上述任一实 施例, 因此该程序代码和存储该程序代码的存储介质是技术方案的一 部分。
用于提供程序代码的存储介质包括软盘、 硬盘、 磁光盘、 光盘(例 如 CD-ROM、 CD-R, CD-RW、 DVD-ROM、 DVD-RAM、 DVD-RW, DVD+RW ) 、 磁盘、 闪存卡、 ROM等等。 可选地, 程序代码也可以通 过通信网络从服务器电脑上下载。
应该注意的是, 对于由计算机执行的程序代码, 至少部分由程序代 码实现的操作可以由运行在计算机上的操作***实现, 从而实现上述 任一实施例的技术方案, 其中该计算机基于程序代码执行指令。
另外, 存储介质中的程序代码被被写入存储器, 其中, 该存储器位 于***在计算机中的扩展板中, 或者位于连接到计算机的扩展单元 中。 在本实施例中, 扩展板或扩展单元中的 CPU根据指令, 基于程序 代码执行至少部分操作, 从而实现上述任一实施例的技术方案。
实际上, 可以通过多种形式来具体实施本发明实施方式所提出的兌 换码的存储和 /或验证方法。 比如, 可以遵循一定规范的应用程序接 口, 将计算机文件运行装置编写为安装到计算机***中的插件程序, 也可以将其封装为应用程序以供用户自行下载使用。 当编写为插件程 序时, 可以将其实施为 ocx、 dll、 cab 等多种插件形式。 也可以通过 Flash插件、 RealPlayer插件、 MMS插件、 MIDI五线谱插件、 ActiveX 插件等具体技术来实施本发明实施方式所提出的兌换码的存储和 /或验 证装置。
综上所述, 在本发明实施方式中, 通过把兌换码设置成字符串与数 值的映射规则, 每个兌换码由一对数值构成, 其中一个数值是随机 值, 另一个数值是与随机值生成顺序相关的索引。 在生成兌换码环节 把数值对映射成字符串, 而且在保存兌换码时只需要存储随机值, 从 而在保证兌换码的破解成功率可控的情形下, 还可以节约数据存储空 间。
而且, 在本发明实施方式中, 在兌换环节把字符串映射成数值对进 行验证, 从而提高兌换码的验证效率。
另外, 可以将本发明实施方式可以应用到各种终端中, 可以跨平台 跨终端使用本发明实施方式, 适用范围非常广泛。
以上所述, 仅为本发明的较佳实施例而已, 并非用于限定本发明的 保护范围。 凡在本发明的精神和原则之内, 所作的任何修改、 等同替 换、 改进等, 均应包含在本发明的保护范围之内。

Claims

权利要求书
1、 一种兌换码的存储方法, 其特征在于, 该方法包括:
生成随机值,并按照所述随机值的生成顺序确定所述随机值的索引; 根据所述随机值以及所述随机值的索引生成数值对, 将所述数值对 映射成字符串, 根据所述字符串生成兌换码;
根据所述随机值的索引确定所述随机值的存储位置, 并在所确定的 存储位置处保存所述随机值。
2、根据权利要求 1所述的兌换码的存储方法, 其特征在于, 该方法 进一步包括:
确定兌换码期望生成数目, 并根据所述兌换码期望生成数目确定所 述索引的位数; 确定兌换码破解概率门限值, 并根据所述兌换码破解概 率门限值确定所述随机值的位数,
所述生成随机值, 并按照所述随机值的生成顺序确定所述随机值的 索引包括: 按照所述随机值的位数生成所述随机值, 并且按照所述随机 值的生成顺序和所述索引的位数确定所述随机值的索引。
3、根据权利要求 1所述的兌换码的存储方法, 其特征在于, 所述根 据所述随机值的索引确定所述随机值的存储位置, 并保存所述随机值包 括:
以位图 (bitmap ), 哈希(hash )或数组(array ) 的方式, 根据所述 随机值的索引确定所述随机值在兌换索引表中的存储位置, 并在所述存 储位置处保存所述随机值, 并且在兌换索引表中保存表明所述随机值是 否已兌换的兌换状态位。
4、根据权利要求 1所述的兌换码的存储方法, 其特征在于, 所述将 所述数值对映射成字符串为: 利用数值到字符串函数(num2str )将所述数值对中的每个数值转换 为对应的 24进制的字符串表示, 并根据每个数值的字符串表示组成字 付 。
5、根据权利要求 1所述的兌换码的存储方法, 其特征在于, 所述将 根据所述字符串生成兌换码包括:
对所述字符串执行混淆处理, 生成所述兌换码。
6、 一种兌换码的验证方法, 其特征在于, 该方法包括:
接收兌换码, 其中所述兌换码的生成方法包括:
生成随机值,并按照所述随机值的生成顺序确定所述随机值的索引; 根据所述随机值以及所述随机值的索引生成数值对, 将所述数值对映射 成字符串, 根据所述字符串生成所述兌换码;
根据兌换码获取字符串, 将所述字符串反映射为数值对, 并按照所 述数值对中的随机值的索引确定存储位置;
当判定所述存储位置处储存的随机值没有被兌换时, 进一步判断所 述数值对中的所述随机值与在所述存储位置处储存的所述随机值是否 一致, 如果是, 则判定兌换码验证成功。
7、 根据权利要求 6所述的兌换码的验证方法, 其特征在于, 当生成所述兌换码时对所述字符串进行了混淆处理时, 根据兌换码 获取字符串包括:
对所述兌换码执行反混淆操作以获取所述字符串。
8、 根据权利要求 6所述的兌换码的验证方法, 其特征在于, 所述将所述数值对映射成字符串包括: 利用数值到字符串函数 ( num2str )将所述数值对中的每个数值转换为对应的 24进制的字符串, 并根据每个数值的字符串组成字符串;
所述将所述字符串反映射为数值对为: 利用字符串到数值函数 ( str2num )将所述字符串中的每个 24进制的字符串表示转换为对应的 数值, 并根据每个数值组成数值对。
9、根据权利要求 6所述的兌换码的验证方法, 其特征在于, 所述按 照所述数值对中的所述随机值的索引确定存储位置为: 按照所述数值对 中的所述随机值的索引确定兌换索引表中的存储位置;
所述当判定所述存储位置处储存的该随机值没有被兌换包括: 根据 兌换索引表中表明随机值是否已兌换的兌换状态位来判定存储位置处 储存的该随机值是否已经兌换; 该方法进一步包括:
当判定兌换码验证成功时, 更新兌换索引表中所述存储位置处随机 值的兌换状态位为已兌换。
10、 一种兌换码的存储装置, 其特征在于, 该装置包括随机值生成 单元、 兌换码生成单元和兌换码存储单元, 其中:
所述随机值生成单元, 用于生成随机值, 并按照所述随机值的生成 顺序确定所述随机值的索引;
所述兌换码生成单元, 用于根据所述随机值以及所述随机值的索引 生成数值对,将所述数值对映射成字符串,根据所述字符串生成兌换码; 所述兌换码存储单元, 用于根据所述随机值的索引确定所述随机值 的存储位置, 并在所确定的存储位置处保存所述随机值。
11、根据权利要求 10所述的兌换码的存储装置, 其特征在于, 进一 步包括位数确定单元, 其中:
所述位数确定单元, 用于确定兌换码期望生成数目, 并根据所述兌 换码期望生成数目确定所述索引的位数; 确定兌换码破解概率门限值, 并根据所述兌换码破解概率门限值确定所述随机值的位数;
所述随机值生成单元,用于按照所述随机值的位数生成所述随机值, 并且按照所述随机值的生成顺序和所述索引的位数确定所述随机值的 索引。
12、 根据权利要求 10所述的兌换码的存储装置, 其特征在于, 所述兌换码存储单元, 用于以位图 (bitmap ), 哈希 (hash )或数组 ( array )的方式, 根据所述随机值的索引确定所述随机值在兌换索引表 中的存储位置, 并在所述存储位置处保存所述随机值, 而且在兌换索引 表中保存表明所述随机值是否已兌换的兌换状态位; 并进一步用于当判 定兌换码验证成功时, 更新兌换索引表中该存储位置处随机值的兌换状 态位状态为已兌换。
13、 根据权利要求 10所述的兌换码的存储装置, 其特征在于, 所述兌换码生成单元, 用于对所述字符串执行混淆处理, 生成所述 兌换码。
14、 一种兌换码的验证装置, 其特征在于, 包括兌换码接收单元、 存储位置确定单元和验证单元, 其中:
所述兌换码接收单元, 用于接收兌换码, 其中该兌换码的生成方法 包括:
生成随机值,并按照所述随机值的生成顺序确定所述随机值的索引; 根据所述随机值以及所述随机值的索引生成数值对, 将所述数值对映射 成字符串, 根据所述字符串生成所述兌换码;
所述存储位置确定单元, 用于根据所述兌换码获取字符串, 将所述 字符串反映射为数值对, 并按照所述数值对中的随机值的索引确定存储 位置;
所述验证单元, 用于当判定所述存储位置处储存的随机值没有被兌 换时, 进一步判断所述数值对中的所述随机值与在所述存储位置处储存 的随机值是否一致, 如果是, 则判定兌换码验证成功。
15、根据权利要求 14所述的兌换码的验证装置,所述存储位置确定 单元进一步用于, 当生成所述兌换码时对所述字符串进行了混淆处理 时, 对所述兌换码执行反混淆操作以获取所述字符串。
16、 根据权利要求 12所述的兌换码的验证装置, 其特征在于, 所述验证单元, 用于根据兌换索引表中表明随机值是否已兌换的兌 换状态位来判断存储位置处储存的该随机值是否已经兌换, 并当判定兌 换码验证成功时, 进一步用于更新兌换索引表中所述存储位置处随机值 的兌换状态位为已兌换。
PCT/CN2013/084865 2012-11-23 2013-10-09 存储和验证兑换码的方法和装置 WO2014079282A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
US14/646,953 US9619657B2 (en) 2012-11-23 2013-10-09 Method and apparatus for storing redeem code, and method and apparatus for verifying redeem code
US15/453,280 US10176304B2 (en) 2012-11-23 2017-03-08 Method and apparatus for storing redeem code, and method and apparatus for verifying redeem code

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201210482877.X 2012-11-23
CN201210482877.XA CN103838753B (zh) 2012-11-23 2012-11-23 一种兑换码的存储、验证方法和装置

Related Child Applications (2)

Application Number Title Priority Date Filing Date
US14/646,953 A-371-Of-International US9619657B2 (en) 2012-11-23 2013-10-09 Method and apparatus for storing redeem code, and method and apparatus for verifying redeem code
US15/453,280 Continuation US10176304B2 (en) 2012-11-23 2017-03-08 Method and apparatus for storing redeem code, and method and apparatus for verifying redeem code

Publications (1)

Publication Number Publication Date
WO2014079282A1 true WO2014079282A1 (zh) 2014-05-30

Family

ID=50775497

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2013/084865 WO2014079282A1 (zh) 2012-11-23 2013-10-09 存储和验证兑换码的方法和装置

Country Status (3)

Country Link
US (2) US9619657B2 (zh)
CN (1) CN103838753B (zh)
WO (1) WO2014079282A1 (zh)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105224414B (zh) * 2015-09-25 2018-01-19 北京奇虎科技有限公司 用于实现业务任务的码的校验方法及装置
CN105468687A (zh) * 2015-11-17 2016-04-06 立德高科(北京)数码科技有限责任公司 一种码值数据随机关联方法与关联***
CN110738507A (zh) * 2018-07-18 2020-01-31 北京京东金融科技控股有限公司 一种兑换码的领取方法和装置
CN109408032A (zh) * 2018-11-01 2019-03-01 郑州云海信息技术有限公司 一种bios客制化快速实现方法、装置、终端及存储介质
CN111723360B (zh) * 2019-03-18 2023-11-03 北京京东尚科信息技术有限公司 凭证码处理方法、装置及存储介质
CN110232601A (zh) * 2019-06-18 2019-09-13 深圳前海微众银行股份有限公司 卡券管理方法、装置、设备及存储介质
CN112953716A (zh) * 2019-11-26 2021-06-11 北京沃东天骏信息技术有限公司 一种兑换码生成及其验证方法和装置
CN111967908A (zh) * 2020-08-17 2020-11-20 深圳市欢太科技有限公司 兑换码的验证方法、电子设备及存储介质
CN113240471A (zh) * 2021-05-19 2021-08-10 完美世界(北京)软件科技发展有限公司 兑奖码的生成方法、生成装置、电子设备及存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101076807A (zh) * 2004-10-15 2007-11-21 弗里塞恩公司 一次性密码
CN102332030A (zh) * 2011-10-17 2012-01-25 中国科学院计算技术研究所 用于分布式键-值存储***的数据存储、管理和查询方法及***
WO2012014231A1 (en) * 2010-07-29 2012-02-02 Nirmal Juthani System and method for generating a strong multi factor personalized server key from a simple user password
CN102752115A (zh) * 2012-07-04 2012-10-24 北京天龙融和软件有限公司 挑战码生成方法及装置、动态口令认证方法及***

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7206411B2 (en) * 2003-06-25 2007-04-17 Wegener Communications, Inc. Rapid decryption of data by key synchronization and indexing
US9270646B2 (en) * 2009-04-20 2016-02-23 Citrix Systems, Inc. Systems and methods for generating a DNS query to improve resistance against a DNS attack
CN101651546A (zh) * 2009-09-11 2010-02-17 福建天晴在线互动科技有限公司 一种离线生成动态密码与服务器进行登陆认证和同步的方法
US8870084B2 (en) * 2011-09-13 2014-10-28 Sca Promotions Method and system for the generation and validation of personal identification numbers
US20160132871A1 (en) * 2012-06-07 2016-05-12 Google Inc. Secure redemption code generation for gift cards and promotions

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101076807A (zh) * 2004-10-15 2007-11-21 弗里塞恩公司 一次性密码
WO2012014231A1 (en) * 2010-07-29 2012-02-02 Nirmal Juthani System and method for generating a strong multi factor personalized server key from a simple user password
CN102332030A (zh) * 2011-10-17 2012-01-25 中国科学院计算技术研究所 用于分布式键-值存储***的数据存储、管理和查询方法及***
CN102752115A (zh) * 2012-07-04 2012-10-24 北京天龙融和软件有限公司 挑战码生成方法及装置、动态口令认证方法及***

Also Published As

Publication number Publication date
CN103838753B (zh) 2018-04-27
CN103838753A (zh) 2014-06-04
US10176304B2 (en) 2019-01-08
US20150278530A1 (en) 2015-10-01
US20170177838A1 (en) 2017-06-22
US9619657B2 (en) 2017-04-11

Similar Documents

Publication Publication Date Title
WO2014079282A1 (zh) 存储和验证兑换码的方法和装置
CN111030822B (zh) 用于保护固件的方法和***,以及计算机可读介质
US10042704B2 (en) Validating stored encoded data slice integrity in a dispersed storage network
US10789062B1 (en) System and method for dynamic data deduplication for firmware updates
US8336100B1 (en) Systems and methods for using reputation data to detect packed malware
US9185119B1 (en) Systems and methods for detecting malware using file clustering
TWI435236B (zh) 惡意程式偵測裝置、惡意程式偵測方法及其電腦程式產品
US8650649B1 (en) Systems and methods for determining whether to evaluate the trustworthiness of digitally signed files based on signer reputation
WO2019160128A1 (ja) ブロックチェーン・ネットワークにおいてトランザクションを検証するための方法及び当該ネットワークを構成するためのノード
US11275835B2 (en) Method of speeding up a full antivirus scan of files on a mobile device
KR20150054380A (ko) 근거리 무선 통신 칩의 펌웨어 업데이트 방법 및 이를 구현하는 전자 시스템
CN110489466B (zh) 邀请码的生成方法、装置、终端设备及存储介质
JP6467540B1 (ja) ブロックチェーン・ネットワークにおいてトランザクションを検証するための方法及び当該ネットワークを構成するためのノード
KR20200126061A (ko) 블록체인 네트워크에서의 트랜잭션의 삭제를 가능하게 하는 노드 장치 및 그 동작 방법
CN105787390A (zh) 一种数据完整性的验证方法及其***
CN111464258B (zh) 一种数据校验方法、装置、计算设备及介质
CN109190358B (zh) 站点密码生成方法、***及密码管理器
KR102375144B1 (ko) 블록체인을 이용하여 개인키를 관리하는 장치, 방법, 시스템 및 컴퓨터 판독가능 저장 매체
CN111949738A (zh) 基于区块链的数据存储去重方法、终端设备和存储介质
KR101893504B1 (ko) 리눅스 환경에서 파일 무결성 검증 장치 및 방법
JP2016130939A (ja) 乱数生成装置、乱数生成方法、およびプログラム
CN111737704B (zh) 用于数据证明的设备和方法
CN115866542B (zh) 短信验证码申请和验证方法、装置、设备及存储介质
KR102398962B1 (ko) 격자 기반 퍼지 추출 장치 및 방법
US20220405372A1 (en) Biometric authentication based on learning parity with noise

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 13857274

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 14646953

Country of ref document: US

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205N DATED 05.10.2015)

122 Ep: pct application non-entry in european phase

Ref document number: 13857274

Country of ref document: EP

Kind code of ref document: A1