EncodingService
Service providing common encoding, hashing, and compression methods.
| Memory category | Instances |
|---|
Member index 7
Description
Service providing common encoding, hashing, and compression methods.
History 8
- 697 Add GetDecompressedBufferSize
- 697 Add DecompressBuffer
- 697 Add ComputeStringHash
- 697 Add ComputeBufferHash
- 697 Add CompressBuffer
- 697 Add Base64Encode
- 697 Add Base64Decode
- 697 Add EncodingService
Members 7
Base64Decode
| Parameters (1) | ||
|---|---|---|
| input | buffer | |
| Returns (1) | ||
| buffer | ||
Method takes a buffer with data encoded in Base64 format and decodes it into a new buffer.
If the input is not valid Base64 data, this method throws an error.
Base64 data is most often used for binary data encoding, so these functions are designed to work on buffer values.
If the data is stored in a string, buffer.fromstring can be used to quickly convert it into a buffer.
| Thread safety | Safe |
|---|
History 1
- 697 Add Base64Decode
Base64Encode
| Parameters (1) | ||
|---|---|---|
| input | buffer | |
| Returns (1) | ||
| buffer | ||
Method takes a buffer with binary data and encodes it using Base64.
Encoded result is returned as a new buffer.
| Thread safety | Safe |
|---|
History 1
- 697 Add Base64Encode
CompressBuffer
| Parameters (3) | Default | |
|---|---|---|
| input | buffer | |
| algorithm | CompressionAlgorithm | |
| compressionLevel | int | 1 |
| Returns (1) | ||
| buffer | ||
Compresses the binary data stored in a buffer using the specified compression algorithm and compression level. The higher the compression level, the longer it takes to compress, but the resulting compression ratio might increase.
For CompressionAlgorithm.Zstd, the allowed compression values are from -7 to 22 inclusive.
| Thread safety | Safe |
|---|
History 1
- 697 Add CompressBuffer
ComputeBufferHash
| Parameters (2) | ||
|---|---|---|
| input | buffer | |
| algorithm | HashAlgorithm | |
| Returns (1) | ||
| buffer | ||
Uses a cryptographic hash function to compute a hash of the input buffer. Returns a new buffer with the binary data.
See descriptions of HashAlgorithm to learn of the supported digest size for each hash.
Do not use this for passwords
None of these hashes are password hashing algorithms. They were designed to be fast to execute, whereas password hashing should never be fast. You shouldn't use this function for computing password hashes that will be stored, or for deriving keys from passwords.
| Thread safety | Safe |
|---|
History 1
- 697 Add ComputeBufferHash
ComputeStringHash
| Parameters (2) | ||
|---|---|---|
| input | string | |
| algorithm | HashAlgorithm | |
| Returns (1) | ||
| string | ||
Uses a cryptographic hash function to compute a hash of the input string. Returns a new string with the binary data.
See descriptions of HashAlgorithm to learn of the supported digest size for each hash.
Do not use this for passwords
None of these hashes are password hashing algorithms. They were designed to be fast to execute, whereas password hashing should never be fast. You shouldn't use this function for computing password hashes that will be stored, or for deriving keys from passwords.
| Thread safety | Safe |
|---|
History 1
- 697 Add ComputeStringHash
DecompressBuffer
| Parameters (2) | ||
|---|---|---|
| input | buffer | |
| algorithm | CompressionAlgorithm | |
| Returns (1) | ||
| buffer | ||
Decompresses the binary data stored in a buffer using the specified compression algorithm.
Decompression might throw an error if the compressed data doesn't contain expected decompressed size, if it is larger than 1GB or if it is invalid.
It is recommended to use EncodingService.GetDecompressedBufferSize to find out the decompressed data size before attempting to decompress. This is very important if the input buffer contents are outside of your control (for example, from a client RemoveEvent)
| Thread safety | Safe |
|---|
History 1
- 697 Add DecompressBuffer
GetDecompressedBufferSize
| Parameters (2) | ||
|---|---|---|
| input | buffer | |
| algorithm | CompressionAlgorithm | |
| Returns (1) | ||
| int? | ||
Reports the size of the decompressed data stored in a compressed
buffer. If the compressed data doesn't have a size or the size
is corrupted or invalid (larger than 1GB), function returns nil. When a
nil is returned, attempting to use
EncodingService.DecompressBuffer on this buffer will
throw an error.
| Thread safety | Safe |
|---|