# US 2021/0288789 A1 · Method and device for file encryption and decryption

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2021/0288789 A1
- Document ID: US20210288789A1
- Status: Published application
- Kind: A1
- Application number: 16/319,687
- Filed: 2017-04-12
- Published: 2021-09-16
- Earliest claimed: 2017-03-20
- Assignees: Wangsu Science & Technology Co., Ltd.
- Applicants: Wangsu Science & Technology Co., Ltd.
- Inventors: Famin CHEN
- Web page: https://patentgrep.com/patent/US20210288789A1

## CPC

- H04L 9/0643: {Hash functions, e.g. MD5, SHA, HMAC or f9 MAC}
- H04L 9/065: {Encryption by serially and continuously modifying data stream elements, e.g. stream cipher systems, RC4, SEAL or A5/3}
- H04L 9/0869: {involving random numbers or seeds}
- H04L: TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION (arrangements common to telegraphic and telephonic communication H04M)

## Abstract

The present disclosure provides a file encryption method. The method includes generating an initial key, retrieving data for encryption in a file, obtaining a length of already encrypted data, calculating an encryption key based on the initial key and the length of the already encrypted data, and using the encryption key to encrypt the data for encryption to obtain encrypted data. Compared to the existing encryption methods, through encrypting each byte of the data in the file, the present disclosure substantially increases the key cracking difficulty and improves the data security.

## Claims

### Claim 1

A file encryption method, comprising:
generating an initial key;
reading to-be-encrypted data in a file;
obtaining a length of already encrypted data in the file, and calculating an encrypted key based on the initial key and the length of the already encrypted data; and
using the encrypted key to encrypt the to-be-encrypted data, thereby obtaining encrypted data.

### Claim 2 (depends on 1)

The file encryption method according to claim 1, wherein:
the encryption key is calculated by plugging the initial key, the length of the initial key, and the length of the already encrypted data into a pre-determined function.

### Claim 3 (depends on 2)

The file encryption method according to claim 2, wherein:
the encryption key calculated by the pre-determined function is divergent.

### Claim 4 (depends on 2)

The file encryption method according to claim 2, wherein:
the pre-determined function is a hash function.

### Claim 5 (depends on 2)

The file encryption method according to claim 2, wherein:
the encryption key has a same length as the initial key.

### Claim 6 (depends on 1)

The file encryption method according to claim 1, wherein generating the initial key includes:
generating the initial key through a random function.

### Claim 7 (depends on 1)

The file encryption method according to claim 1, wherein:
the initial key is an array.

### Claim 8 (depends on 1)

The file encryption method according to claim 1, wherein:
when the encrypted key is used to encrypt the to-be-encrypted data, each byte of the to-be-encrypted data is encrypted individually.

### Claim 9 (depends on 1)

The file encryption method according to claim 1, wherein:
the encrypted data is obtained by performing a logic XOR operation on the encrypted key and the to-be-encrypted data.

### Claim 10 (depends on 1)

The file encryption method according to claim 1, wherein:
the file is a streaming media file.

### Claim 11 (depends on 1)

The file encryption method according to claim 1, wherein:
when being read, the to-be-encrypted data in the file is read sectionally in an order.

### Claim 12 (depends on 1)

The file encryption method according to claim 1, further including:
storing the initial key.

### Claim 13

An encrypted file decryption method, comprising:
acquiring an initial key;
reading to-be-decrypted data from an encrypted file;
obtaining a length of already decrypted data in a file and calculating a decrypted key based on the initial key and the length of the already decrypted data; and
using the decrypted key to decrypt the to-be-decrypted data, thereby obtaining decrypted data.

### Claim 14 (depends on 13)

The encrypted file decryption method according to claim 13, wherein:
the decryption key is calculated by plugging the initial key, the length of the initial key, and the length of the already decrypted data into a pre-determined function.

### Claim 15 (depends on 14)

The encrypted file decryption method according to claim 14, wherein:
the pre-determined function for decryption is the same as the pre-determined function for encryption.

### Claim 16 (depends on 13)

The encrypted file decryption method according to claim 13, wherein:
the initial key is the same as the initial key used in file encryption.

### Claim 17 (depends on 13)

The encrypted file decryption method according to claim 13, wherein:
when the decrypted key is used to decrypt the to-be-decrypted data, each byte of the to-be-decrypted data is decrypted individually.

### Claim 18 (depends on 13)

The encrypted file decryption method according to claim 13, wherein:
the decrypted data is obtained by performing a logic XOR operation on the decrypted key and the to-be-decrypted data.

### Claim 19 (depends on 13)

The encrypted file decryption method according to claim 13, wherein:
the file is a streaming media file.

### Claim 20 (depends on 13)

The encrypted file decryption method according to claim 13, wherein:
a method of reading the to-be-decrypted data is the same as a method of reading the to-be-encrypted data when the file is encrypted.

### Claim at position 21

-38. (canceled)
