CN108572964B - Method and device for generating file name - Google Patents

Method and device for generating file name Download PDF

Info

Publication number
CN108572964B
CN108572964B CN201710136365.0A CN201710136365A CN108572964B CN 108572964 B CN108572964 B CN 108572964B CN 201710136365 A CN201710136365 A CN 201710136365A CN 108572964 B CN108572964 B CN 108572964B
Authority
CN
China
Prior art keywords
string
character string
identifier
character
level timestamp
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN201710136365.0A
Other languages
Chinese (zh)
Other versions
CN108572964A (en
Inventor
熊超
陈少杰
张文明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Dongyin Technology Co ltd
Original Assignee
Wuhan Douyu Network Technology Co Ltd
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 Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Priority to CN201710136365.0A priority Critical patent/CN108572964B/en
Publication of CN108572964A publication Critical patent/CN108572964A/en
Application granted granted Critical
Publication of CN108572964B publication Critical patent/CN108572964B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Information Transfer Between Computers (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention provides a method and a device for generating file names, wherein the method comprises the following steps: acquiring a user identifier of an uploaded file and a current second-level timestamp of a server; converting the user identification and the second-level timestamp into a first character string by using a first conversion rule; calculating a first identifier according to the current microsecond-level timestamp of the server; converting the first identifier into a second string using an encryption algorithm; converting the first character string and the second character string into the file name by using a second conversion rule; thus, the first identifier calculated using the server's current microsecond timestamp is already accurate to the millisecond level, with a probability of renaming of one in a thousand, and then the second string into which the first identifier is further converted using a cryptographic algorithm is absolutely irreversible; and finally, converting the first character string and the second character string into the file name by using a second conversion rule, so that the uniqueness of the file name is ensured.

Description

Method and device for generating file name
Technical Field
The invention belongs to the technical field of Internet application, and particularly relates to a method and a device for generating a file name.
Background
With the increasing development of the internet industry, more and more netizens are provided, and users can upload own files or videos to websites at any time.
However, with the development of the User created Content (UGC) industry, the number of files uploaded by a User is too large, files with the same name are too many, and the uniqueness of file uploading names cannot be completely achieved, so that an administrator is inconvenient to manage and retrieve the files, and the work efficiency is reduced.
Disclosure of Invention
Aiming at the problems in the prior art, the embodiment of the invention provides a method and a device for generating a file name, which are used for solving the technical problems that in the prior art, due to the fact that the file amount uploaded to a website by a user is too much, the file name cannot be unique, and therefore when an administrator manages the file name, the retrieval process is complicated, and further the working efficiency is reduced.
The invention provides a method for generating a file name, which comprises the following steps:
acquiring a user identifier of an uploaded file and a current second-level timestamp of a server;
converting the user identification and the second-level timestamp into a first character string by using a first conversion rule;
calculating a first identifier according to the current microsecond-level timestamp of the server;
converting the first identifier into a second string using an encryption algorithm;
and converting the first character string and the second character string into the file name by using a second conversion rule.
In the foregoing solution, the obtaining a current second-level timestamp of the server includes:
calling date ('YmdHis', now ()) method converts the second-level timestamp into a string of the second-level timestamp.
In the foregoing solution, converting the user identifier and the second-level timestamp into a first character string by using a first conversion rule includes:
acquiring a character string of the user identifier and a character string of the second-level timestamp;
determining a first inserting position of the character string of the user identification in the character string of the second-level timestamp based on a confusion algorithm according to the character string of the second-level timestamp;
inserting the user-identified string into the first insertion location in the string of the second-level timestamp.
In the foregoing solution, the determining, according to the string of the second-level timestamp, a first insertion position of the string of the user identifier in the string of the second-level timestamp based on a confusion algorithm includes:
determining a first reference bit of a string of the second-level timestamp;
acquiring a first numerical value of a character corresponding to the first reference bit;
determining the first insertion location based on the first value.
In the foregoing solution, before the calculating the first identifier according to the current microsecond-level timestamp of the server, the method further includes:
and adding a second identifier in the first character string to form a third character string.
In the foregoing scheme, the adding a second identifier to the first character string to form a third character string includes:
determining a second reference bit of the first string;
acquiring a second numerical value of the character corresponding to the second reference bit;
determining an addition location in the first string based on the second value;
adding the second identifier to the first string at the addition location to form the third string.
In the foregoing solution, the converting the first identifier into the second character string by using an encryption algorithm includes:
calling a function RAND () to obtain an integer, wherein the value of the integer is between 0 and 99999;
concatenating the integer with the first identifier;
the concatenated string is converted into the second string by a hash hashing algorithm MD5 ().
In the foregoing solution, converting the first character string and the second character string into the file name by using a second conversion rule includes:
acquiring the third character string;
determining a third reference bit of the third string;
acquiring characters of the third reference position;
converting the character of the third reference bit into a third numerical value according to a preset third conversion rule;
determining a second insertion position of the second character string in the third character string based on the third numerical value;
inserting the second character string into the second insertion position in the third character string to form a fourth character string; the fourth character string is the file name.
The present invention also provides a device for generating a file name, the device comprising:
the acquisition unit is used for acquiring a user identifier of an uploaded file and a current second-level timestamp of the server;
the first conversion unit is used for converting the user identification and the second-level timestamp into a first character string by using a first conversion rule;
the computing unit is used for computing a first identifier according to the current microsecond-level timestamp of the server;
a second conversion unit for converting the first identifier into a second character string using an encryption algorithm;
and the third conversion unit is used for converting the first character string and the second character string into the file name by utilizing a second conversion rule.
In the scheme, the character string of the user identifier and the character string of the second-level timestamp are obtained;
determining a first inserting position of the character string of the user identification in the character string of the second-level timestamp based on a confusion algorithm according to the character string of the second-level timestamp;
inserting the user-identified string into the first insertion location in the string of the second-level timestamp.
The invention provides a method and a device for generating file names, wherein the method comprises the following steps: acquiring a user identifier of an uploaded file and a current second-level timestamp of a server; converting the user identification and the second-level timestamp into a first character string by using a first conversion rule; calculating a first identifier according to the current microsecond-level timestamp of the server; converting the first identifier into a second string using an encryption algorithm; converting the first character string and the second character string into the file name by using a second conversion rule; thus, the first identifier calculated using the current microsecond timestamp of the server is already accurate to the millisecond level, the probability of its renaming is one thousandth, and then the second string into which the first identifier is further converted using an encryption algorithm is absolutely irreversible; and finally, converting the first character string and the second character string into the file name by using a second conversion rule, so that the uniqueness of the file name is ensured, and when an administrator manages the file again, the file can be retrieved and managed according to the unique file name, thereby improving the working efficiency.
Drawings
Fig. 1 is a schematic flowchart of a method for generating a file name according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of a device for generating a file name according to a second embodiment of the present invention.
Detailed Description
In order to solve the technical problems that in the prior art, due to the fact that the file quantity uploaded to a website by a user is too much and the file name cannot be unique, when an administrator manages the file, the retrieval process is complicated, and the working efficiency is further reduced, the invention provides a method and a device for generating the file name, wherein the method comprises the following steps: acquiring a user identifier of an uploaded file and a current second-level timestamp of a server; converting the user identification and the second-level timestamp into a first character string by using a first conversion rule; calculating a first identifier according to the current microsecond-level timestamp of the server; converting the first identifier into a second string using an encryption algorithm; converting the first character string and the second character string into the file name by using a second conversion rule;
the technical solution of the present invention is further described in detail by the accompanying drawings and the specific embodiments.
Example one
The present embodiment provides a method for generating a file name, as shown in fig. 1, the method includes:
s101, acquiring a user identification of an uploaded file and a current second-level timestamp of a server.
In this step, if the user has logged in the server, the user identifier Uid allocated by the user in the server may be obtained, and specifically, the user identifier Uid may be obtained by $ _ SESSION [ 'Uid' ], and the user identifier Uid may be any value from 0 to 65535. The value of the user identity Uid may be 10000, for example.
After the user Uid is acquired, the current second-level timestamp of the server is acquired by calling a system self-carrying method now (), the second-level timestamp of the system is converted into a format corresponding to time, minute and second of the year, month and day by using a system function date (), and then a date ('YmdHis', new ()) method is called to convert the second-level timestamp into a character string $ str of the second-level timestamp. For example, the string $ str for a second-level timestamp may be 20170220151615.
S102, converting the user identification and the second-level timestamp into a first character string by using a first conversion rule.
In this step, after the user identifier Uid and the string of the second-level timestamp are acquired, the user identifier and the second-level timestamp may be converted into a first string by using a first conversion rule. Specifically, a first inserting position of the character string of the Uid of the user in the character string of the second-level timestamp is determined according to the character string of the second-level timestamp based on a confusion algorithm; inserting the string of the user Uid into the first insertion position in the string of the second-level timestamp.
When the first insertion position is determined, the method specifically comprises the following steps: determining a first reference bit of a string of the second-level timestamp; acquiring a first numerical value of a character corresponding to the first reference bit; determining the first insertion location based on the first value.
Wherein the first conversion rule may include a plurality of: for example, characters are correspondingly converted with decimal values, and characters are correspondingly converted with ASCII code values.
When characters and ASCII code values are correspondingly converted, acquiring a first reference bit of a character string of the second-level timestamp, acquiring a character corresponding to the first reference bit, and inserting the character string of the Uid of the user into a corresponding position in the character string of the second-level timestamp by taking the ASCII code value corresponding to the character as a reference value.
Here, the first reference bit of the string of the second-level timestamp may be any bit in the string, such as the first bit or the last bit, and when the last bit is set as the first reference bit, if the string of the second-level timestamp is 20170220151615, the character of the first reference bit is "5", and then the ASCII code corresponding to "5" is acquired as "53", and then the string of the user Uid is inserted into a position after the 53 th character of the string of the second-level timestamp, wherein if the string of the second-level timestamp does not have so many characters, 0 may be substituted.
Of course, the determining, according to the string of the second-level timestamp, a first insertion position of the string of the user Uid in the string of the second-level timestamp based on a obfuscation algorithm may further include:
and determining a first reference bit of the character string of the second-level timestamp, wherein the first reference bit is the first inserting position.
For example, the first reference bit of the string of the second-level timestamp may be any bit in the string, such as the first bit or the last bit, and when the last bit is set as the first reference bit, if the string of the second-level timestamp is 20170220151615, the character of the first reference bit is "5", and then the string of the user Uid is inserted into a position after the last character "5" of the string of the second-level timestamp.
S103, calculating a first identifier according to the current microsecond-level timestamp of the server, and converting the first identifier into a second character string by using an encryption algorithm.
In this step, a system function UNIQID () method is called to obtain a first identifier calculated from the current microsecond-level timestamp of the server, where the first identifier is a unique ID, but in the case of distributed high concurrency, even if the accuracy is as accurate as milliseconds, the repetition rate of the ID is still high. Therefore, the first identifier needs to be encrypted by an encryption algorithm to ensure uniqueness. For example, the string of the first identifier may be "4 b3403665fea 6".
After calculating the first identifier, in order to reduce the repetition rate, the first identifier is further converted into a second character string by using an encryption algorithm, including: calling a function RAND () to obtain an integer, wherein the value of the integer is between 0 and 99999; such as: 1001; concatenating the integer with the first identifier; the concatenated string is converted into the second string by a hash hashing algorithm MD5 (). For example, the character string formed after splicing is: 4b3403665fea61001, the second character string converted by the hash algorithm MD5() is: "856063 a71571583eee4b28dc4d4aadf 7".
Or the spliced character string can be converted into the second character string through Base64 encoding.
It should be noted that, before calculating the first identifier according to the current microsecond-level timestamp of the server, the method further includes: and adding a second identifier in the first character string to form a third character string.
Specifically, after the first character string is acquired, in order to distinguish the first character string from other files in the server, a specific second identifier may be added to the first character string to form a third character string. For example, the first identifier may be "-upload-", or other identifiers.
Specifically, the adding a second identifier to the first character string to form a third character string includes: determining a second reference bit of the first string; acquiring a second numerical value of the character corresponding to the second reference bit; determining an addition location in the first string based on the second value; adding the second identifier to the first string at the addition location to form the third string.
For example, when the characters are converted into corresponding ASCII code values, the second reference bit of the first character string is obtained, the character corresponding to the second reference bit is obtained, the ASCII code value corresponding to the character is inserted into the corresponding position in the first character string using the ASCII code value as a reference value, and then the second identifier is inserted into the corresponding position in the first character string.
Here, the second reference bit of the first character string may be any one bit in the character string, such as the first bit or the last bit or other bits, when the last bit is set as the second reference bit, if the first character string is "1000020170220151615", the character of the second reference bit is "5", the corresponding ASCII code of "5" is obtained as "53", and then the second identifier is inserted into a position after the 53 th character of the first character string, wherein if the first character string does not have so many characters, 0 may be substituted.
Of course, adding the second identifier to the first string, forming the third string may further include: and determining a second reference bit of the first character string, wherein the second reference bit is an adding position.
The second reference bit of the first string may be any bit in the first string, such as the first bit or the last bit, and when the last bit is set as the second reference bit, if the first string is "1000020170220151615", the character of the second reference bit is "5", and then the first identifier is inserted into a position after the last character "5" of the first string. Then the third string formed may be "1000020170220151615-upload-".
And S104, converting the first character string and the second character string into the file name by using a second conversion rule.
In this step, after the third character string is obtained, the first character string and the second character string are converted into the file name by using a second conversion rule.
Specifically, a third reference bit of the third string is determined; acquiring characters of the third reference position; converting the character of the third reference bit into a third numerical value according to a preset third conversion rule; determining a second insertion position of the second character string in the third character string based on the third numerical value; inserting the second character string into the second insertion position in the third character string to form a fourth character string; the fourth character string is the file name.
Wherein, the third conversion rule may include a plurality of kinds: for example, characters are correspondingly converted with decimal values, and characters are correspondingly converted with ASCII code values.
When characters are correspondingly converted from the ASCII code values, a third reference bit of the third character string is obtained, characters corresponding to the third reference bit are obtained, the ASCII code values corresponding to the characters are used as reference values, and the second character string is inserted into the corresponding position in the third character string.
Here, the third reference bit of the third string may be any one bit in the string, such as the first bit or the last bit or other bits, when the fifteenth bit is set as the third reference bit, if the third string is "1000020170220151615-upload", the character of the third reference bit is "5", and then the ASCII code corresponding to "5" is acquired as "53", and then the second string is inserted into a position after the 53 th character of the third string, wherein if the third string does not have so many characters, 0 may be substituted.
Of course, this may also include:
and determining a third reference bit of the third character string, wherein the third reference bit is the second insertion position.
For example, the third reference bit of the third string may be any bit in the string, such as the first bit or the last bit, when the last bit is set as the third reference bit, if the third string is "1000020170220151615-upload", the character of the third reference bit is "d", and then the second string is inserted into a position behind the last character "d" of the third string to form a fourth string, where the fourth string is the file name.
The first identifier calculated by the present microsecond timestamp of the server is accurate to millisecond, the probability of the duplicate name is one thousandth, and then the second character string converted from the first identifier by the encryption algorithm is absolutely irreversible; and finally, converting the first character string and the second character string into the file name by using a second conversion rule, so that the uniqueness of the file name is ensured.
Example two
Corresponding to the first embodiment, this embodiment further provides an apparatus for generating a file name, as shown in fig. 2, the apparatus includes: an acquisition unit 21, a first conversion unit 22, a calculation unit 23, a second conversion unit 24, a third conversion unit 25, and an addition unit 26; wherein,
if the user has logged in the server, the obtaining unit 21 may obtain the user identifier Uid allocated by the user in the server, and specifically may obtain the user identifier Uid through $ _ SESSION [ 'Uid' ] and the user identifier Uid may be any value from 0 to 65535. The value of the user identity Uid may be 10000, for example.
After the obtaining unit 21 obtains the user Uid, it needs to obtain the current second-level timestamp of the server by calling a system own method now (), convert the second-level timestamp of the system into a format corresponding to time, month, day, minute and second by using a system function date (), and then convert the second-level timestamp into a string $ str of the second-level timestamp by calling a date ('ymdHis', now ()) method. For example, the string $ str for a second-level timestamp may be 20170220151615.
After the obtaining unit 21 obtains the user identifier of the uploaded file and the current second-level timestamp of the server, the first converting unit 22 is configured to convert the user identifier and the second-level timestamp into a first character string by using a first conversion rule.
Specifically, the first conversion unit 22 first determines a first insertion position of the user Uid character string in the second-level timestamp character string according to the second-level timestamp character string based on a confusion algorithm; inserting the string of the user Uid into the first insertion position in the string of the second-level timestamp.
When determining the first insertion position, the first conversion unit 22 specifically includes: determining a first reference bit of a string of the second-level timestamp; acquiring a first numerical value of a character corresponding to the first reference bit; determining the first insertion location based on the first value.
Wherein the first conversion rule may include a plurality of: for example, characters are correspondingly converted with decimal values, and characters are correspondingly converted with ASCII code values.
When characters and ASCII code values are correspondingly converted, acquiring a first reference bit of a character string of the second-level timestamp, acquiring a character corresponding to the first reference bit, and inserting the character string of the Uid of the user into a corresponding position in the character string of the second-level timestamp by taking the ASCII code value corresponding to the character as a reference value.
Here, the first reference bit of the string of the second-level timestamp may be any bit in the string, such as the first bit or the last bit, and when the last bit is set as the first reference bit, if the string of the second-level timestamp is 20170220151615, the character of the first reference bit is "5", and then the ASCII code corresponding to "5" is acquired as "53", and then the string of the user Uid is inserted into a position after the 53 th character of the string of the second-level timestamp, wherein if the string of the second-level timestamp does not have so many characters, 0 may be substituted.
Of course, the determining, by the first conversion unit 22, the first insertion position of the character string of the user Uid in the character string of the second-level timestamp based on a confusion algorithm according to the character string of the second-level timestamp may further include:
and determining a first reference bit of the character string of the second-level timestamp, wherein the first reference bit is the first inserting position.
For example, the first reference bit of the string of the second-level timestamp may be any bit in the string, such as the first bit or the last bit, and when the last bit is set as the first reference bit, if the string of the second-level timestamp is 20170220151615, the character of the first reference bit is "5", and then the string of the user Uid is inserted into a position after the last character "5" of the string of the second-level timestamp.
After the first character string is formed, the calculating unit 23 is configured to calculate a first identifier according to the current microsecond timestamp of the server, and the second converting unit 24 is configured to convert the first identifier into a third character string by using an encryption algorithm.
Specifically, the calculation unit 23 calls the UNIQID () method to obtain the first identifier calculated from the current microsecond-level timestamp of the server, which is a unique ID, but in the case of distributed high concurrency, the repetition rate of IDs is still high even if it is accurate to milliseconds. Therefore, the first identifier needs to be encrypted by an encryption algorithm to ensure uniqueness. For example, the string of the first identifier may be "4 b3403665fea 6".
After calculating the first identifier, in order to reduce the repetition rate, the second converting unit 24 further needs to convert the first identifier into a second character string by using an encryption algorithm, which includes: calling a function RAND () to obtain an integer, wherein the value of the integer is between 0 and 99999; such as: 1001; concatenating the integer with the first identifier; the concatenated string is converted into the second string by a hash hashing algorithm MD5 (). For example, the character string formed after splicing is: 4b3403665fea61001, the second character string converted by the hash algorithm MD5() is: "856063 a71571583eee4b28dc4d4aadf 7".
Or the second conversion unit 24 may also convert the spliced character string into the second character string by Base64 encoding.
Here, the apparatus further includes: an adding unit 26, before calculating the first identifier according to the current microsecond-level timestamp of the server, the adding unit 26 is configured to: and adding a second identifier in the first character string to form a third character string.
Specifically, after the first character string is acquired, the adding unit 26 may add a specific second identifier to the first character string to form a third character string in order to distinguish the first character string from other files in the server. For example, the first identifier may be "-upload-", or other identifiers.
Specifically, the adding unit 26 adds a second identifier to the first character string to form a third character string, including: determining a second reference bit of the first string; acquiring a second numerical value of the character corresponding to the second reference bit; determining an addition location in the first string based on the second value; adding the second identifier to the first string at the addition location to form the third string.
For example, when the characters are converted into corresponding ASCII code values, the second reference bit of the first character string is obtained, the character corresponding to the second reference bit is obtained, the ASCII code value corresponding to the character is inserted into the corresponding position in the first character string using the ASCII code value as a reference value, and then the second identifier is inserted into the corresponding position in the first character string.
Here, the second reference bit of the first character string may be any one bit in the character string, such as the first bit or the last bit or other bits, when the last bit is set as the second reference bit, if the first character string is "1000020170220151615", the character of the second reference bit is "5", the corresponding ASCII code of "5" is obtained as "53", and then the second identifier is inserted into a position after the 53 th character of the first character string, wherein if the first character string does not have so many characters, 0 may be substituted.
Of course, adding the second identifier to the first string, forming the third string may further include: and determining a second reference bit of the first character string, wherein the second reference bit is an adding position.
The second reference bit of the first string may be any bit in the first string, such as the first bit or the last bit, and when the last bit is set as the second reference bit, if the first string is "1000020170220151615", the character of the second reference bit is "5", and then the first identifier is inserted into a position after the last character "5" of the first string. Then the third string formed may be "1000020170220151615-upload-".
Correspondingly, the third conversion unit 25 is configured to convert the first character string and the second character string into the file name by using a second conversion rule. Specifically, the third conversion unit 25 determines a third reference bit of the third string; acquiring characters of the third reference position; converting the character of the third reference bit into a third numerical value according to a preset third conversion rule; determining a second insertion position of the second character string in the third character string based on the third numerical value; inserting the second character string into the second insertion position in the third character string to form a fourth character string; the fourth character string is the file name.
Wherein, the third conversion rule may include a plurality of kinds: for example, characters are correspondingly converted with decimal values, and characters are correspondingly converted with ASCII code values.
When characters are correspondingly converted from the ASCII code values, a third reference bit of the third character string is obtained, characters corresponding to the third reference bit are obtained, the ASCII code values corresponding to the characters are used as reference values, and the second character string is inserted into the corresponding position in the third character string.
Here, the third reference bit of the third string may be any one bit in the string, such as the first bit or the last bit or other bits, when the fifteenth bit is set as the third reference bit, if the third string is "1000020170220151615-upload", the character of the third reference bit is "5", and then the ASCII code corresponding to "5" is acquired as "53", and then the second string is inserted into a position after the 53 th character of the third string, wherein if the third string does not have so many characters, 0 may be substituted.
Of course, the third conversion unit 25 is also configured to:
and determining a third reference bit of the third character string, wherein the third reference bit is the second insertion position.
For example, the third reference bit of the third string may be any bit in the string, such as the first bit or the last bit, when the last bit is set as the third reference bit, if the third string is "1000020170220151615-upload", the character of the third reference bit is "d", and then the second string is inserted into a position behind the last character "d" of the third string to form a fourth string, where the fourth string is the file name.
The method and the device for generating the file name provided by the embodiment have the beneficial effects that at least:
the invention provides a method and a device for generating file names, wherein the method comprises the following steps: acquiring a user identifier of an uploaded file and a current second-level timestamp of a server; converting the user identification and the second-level timestamp into a first character string by using a first conversion rule; calculating a first identifier according to the current microsecond-level timestamp of the server; converting the first identifier into a second string using an encryption algorithm; converting the first character string and the second character string into the file name by using a second conversion rule; thus, the first identifier calculated using the current microsecond timestamp of the server is already accurate to the millisecond level, the probability of its renaming is one thousandth, and then the second string into which the first identifier is further converted using an encryption algorithm is absolutely irreversible; and finally, converting the first character string and the second character string into the file name by using a second conversion rule, so that the uniqueness of the file name is ensured, and when an administrator manages the file again, the file can be retrieved and managed according to the unique file name, thereby improving the working efficiency.
The above description is only exemplary of the present invention and should not be taken as limiting the scope of the present invention, and any modifications, equivalents, improvements, etc. that are within the spirit and principle of the present invention should be included in the present invention.

Claims (7)

1. A method of generating a file name, the method comprising:
acquiring a user identifier of an uploaded file and a current second-level timestamp of a server;
converting the user identification and the second-level timestamp into a first character string by using a first conversion rule;
calculating a first identifier according to the current microsecond-level timestamp of the server;
converting the first identifier into a second string using an encryption algorithm;
converting the first character string and the second character string into the file name by using a second conversion rule; wherein,
before calculating the first identifier according to the current microsecond-level timestamp of the server, the method further comprises the following steps:
adding a second identifier in the first character string to form a third character string;
adding a second identifier to the first character string to form a third character string, including:
determining a second reference bit of the first string;
acquiring a second numerical value of the character corresponding to the second reference bit;
determining an addition location in the first string based on the second value;
adding the second identifier to the first string at the addition location to form the third string;
converting the first character string and the second character string into the file name by using a second conversion rule, including:
acquiring the third character string;
determining a third reference bit of the third string;
acquiring characters of the third reference position;
converting the character of the third reference bit into a third numerical value according to a preset third conversion rule;
determining a second insertion position of the second character string in the third character string based on the third numerical value;
inserting the second character string into the second insertion position in the third character string to form a fourth character string; the fourth character string is the file name.
2. The method of claim 1, wherein obtaining the server's current second-level timestamp comprises:
calling date ('YmdHis', now ()) method converts the second-level timestamp into a string of the second-level timestamp.
3. The method of claim 1 or 2, wherein converting the user identification and the second-level timestamp to a first string using a first conversion rule comprises:
acquiring a character string of the user identifier and a character string of the second-level timestamp;
determining a first inserting position of the character string of the user identification in the character string of the second-level timestamp based on a confusion algorithm according to the character string of the second-level timestamp;
inserting the user-identified string into the first insertion location in the string of the second-level timestamp.
4. The method of claim 3, wherein said determining a first insertion location of said user-identified string in said second-level timestamp string based on a obfuscation algorithm based on said second-level timestamp string comprises:
determining a first reference bit of a string of the second-level timestamp;
acquiring a first numerical value of a character corresponding to the first reference bit;
determining the first insertion location based on the first value.
5. The method of claim 1, wherein said converting the first identifier to a second string using an encryption algorithm comprises:
calling a function RAND () to obtain an integer, wherein the value of the integer is between 0 and 99999;
concatenating the integer with the first identifier;
the concatenated string is converted into the second string by a hash hashing algorithm MD5 ().
6. An apparatus for generating a file name, the apparatus comprising:
the acquisition unit is used for acquiring a user identifier of an uploaded file and a current second-level timestamp of the server;
the first conversion unit is used for converting the user identification and the second-level timestamp into a first character string by using a first conversion rule;
the computing unit is used for computing a first identifier according to the current microsecond-level timestamp of the server;
a second conversion unit for converting the first identifier into a second character string using an encryption algorithm;
a third conversion unit configured to convert the first character string and the second character string into the file name using a second conversion rule; wherein,
before calculating the first identifier according to the current microsecond-level timestamp of the server, the method further comprises the following steps:
adding a second identifier in the first character string to form a third character string;
adding a second identifier to the first character string to form a third character string, including:
determining a second reference bit of the first string;
acquiring a second numerical value of the character corresponding to the second reference bit;
determining an addition location in the first string based on the second value;
adding the second identifier to the first string at the addition location to form the third string;
converting the first character string and the second character string into the file name by using a second conversion rule, including:
acquiring the third character string;
determining a third reference bit of the third string;
acquiring characters of the third reference position;
converting the character of the third reference bit into a third numerical value according to a preset third conversion rule;
determining a second insertion position of the second character string in the third character string based on the third numerical value;
inserting the second character string into the second insertion position in the third character string to form a fourth character string; the fourth character string is the file name.
7. The apparatus of claim 6, wherein the first conversion unit is to:
acquiring a character string of the user identifier and a character string of the second-level timestamp;
determining a first inserting position of the character string of the user identification in the character string of the second-level timestamp based on a confusion algorithm according to the character string of the second-level timestamp;
inserting the user-identified string into the first insertion location in the string of the second-level timestamp.
CN201710136365.0A 2017-03-09 2017-03-09 Method and device for generating file name Active CN108572964B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710136365.0A CN108572964B (en) 2017-03-09 2017-03-09 Method and device for generating file name

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710136365.0A CN108572964B (en) 2017-03-09 2017-03-09 Method and device for generating file name

Publications (2)

Publication Number Publication Date
CN108572964A CN108572964A (en) 2018-09-25
CN108572964B true CN108572964B (en) 2022-01-04

Family

ID=63577903

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710136365.0A Active CN108572964B (en) 2017-03-09 2017-03-09 Method and device for generating file name

Country Status (1)

Country Link
CN (1) CN108572964B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101123502A (en) * 2007-08-28 2008-02-13 浙江大学 Measurement authentication method based on digital signature
CN100492365C (en) * 2007-05-11 2009-05-27 北京中星微电子有限公司 File name generating method and device in file distribution system
CN101533414A (en) * 2009-04-15 2009-09-16 阿里巴巴集团控股有限公司 A method and a device for generating unique identifier of database record
CN105590064A (en) * 2015-12-14 2016-05-18 中国建设银行股份有限公司 File processing method, file processing device and file server

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100492365C (en) * 2007-05-11 2009-05-27 北京中星微电子有限公司 File name generating method and device in file distribution system
CN101123502A (en) * 2007-08-28 2008-02-13 浙江大学 Measurement authentication method based on digital signature
CN101533414A (en) * 2009-04-15 2009-09-16 阿里巴巴集团控股有限公司 A method and a device for generating unique identifier of database record
CN105590064A (en) * 2015-12-14 2016-05-18 中国建设银行股份有限公司 File processing method, file processing device and file server

Also Published As

Publication number Publication date
CN108572964A (en) 2018-09-25

Similar Documents

Publication Publication Date Title
CN106933854B (en) Short link processing method and device and server
US11206147B2 (en) Method and apparatus for generating a cryptographic time stamp for a digital document on a majority basis
CN105373927B (en) Ticket code generation method and device of electronic ticket and server
EP3347814A1 (en) Identifying software components in a software codebase
CN111756522A (en) Data processing method and system
CN102402558A (en) Method and system for providing message containing website
CN105279258B (en) File storage method and system with balanced distribution
CN106649360B (en) Data repeatability checking method and device
CN110019200B (en) Index establishing and using method and device
Gao et al. A decentralized trusted timestamping based on blockchains
CN107451467A (en) A kind of weak passwurd check method and device
CN110634052A (en) Method and device for generating order number by distributed architecture
WO2019091018A1 (en) Knowledge graph establishment method and device, computer device and storage medium
Bryan et al. Javascript object notation (json) pointer
CN108093026A (en) The processing method and processing device of multi-tenant request
CN110334103B (en) Recommendation service updating method, providing device, access device and recommendation system
CN107635028B (en) Resource naming method and device, block chain cluster and electronic equipment
CN104765882A (en) Internet website statistics method based on web page characteristic strings
US20200143076A1 (en) Method for a secure storage of data records
CN113407560B (en) Update message processing method, data synchronization method and configuration information configuration method
TW201426337A (en) System and method for creating object files
CN108572964B (en) Method and device for generating file name
CN111866134B (en) Method and system for generating hash value and address of block chain transaction and storage medium
CN117725062A (en) Database table processing method and device, storage medium and computer equipment
CN110458566B (en) Block chain account address generation method, system and device and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20240703

Address after: Building 53, Binyangli, Miyun District, Beijing 101599, 1st to 2nd floors, No. 11 (1st floor)

Patentee after: Beijing Dongyin Technology Co.,Ltd.

Country or region after: China

Address before: 430000 floor 11, building B1, phase 4.1, software industry, No. 1, Software Park East Road, Donghu Development Zone, Huangshi City, Hubei Province

Patentee before: WUHAN DOUYU NETWORK TECHNOLOGY Co.,Ltd.

Country or region before: China

TR01 Transfer of patent right