API Reference#
A python module for very basic APIs of the free dweet service with encryption.
- Author: Quan Lin
- License: MIT
CryptoDweet(aes_cbc_key=b'aes_cbc_key', aes_cbc_iv=None, base_url=BASE_URL)
#
A class for the free dweet service with encryption.
Initialization options:
CryptoDweet()
: With default key and iv, not secure.CryptoDweet("YOUR KEY")
: Only set key, and iv is the same as key.CryptoDweet("YOUR KEY", "YOUR IV")
: Set both key and iv, strongest encryption.
The given key is padded with space to 16 bytes (if shorter than 16 bytes) or padded with space to 32 bytes (if length is between 16 and 32) or truncated to 32 bytes (if longer than 32 bytes). The given iv is padded with space or truncated to 16 bytes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
aes_cbc_key |
bytes
|
The key of AES CBC mode. |
b'aes_cbc_key'
|
aes_cbc_iv |
bytes
|
The IV of AES CBC mode. |
None
|
base_url |
str
|
The base url of the dweet server. |
BASE_URL
|
dweet_for(thing, content_dict)
#
The 'dweet for' API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
thing |
str
|
The thing name. |
required |
content_dict |
dict
|
The content dict. |
required |
Returns:
Type | Description |
---|---|
dict
|
The result dict of 'dweet for' API. |
get_dweets_for(thing)
#
The 'get dweets for' API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
thing |
str
|
The thing name. |
required |
Returns:
Type | Description |
---|---|
list
|
The result list of dict of 'get dweets for' API. |
get_latest_dweet_for(thing)
#
The 'get latest dweet for' API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
thing |
str
|
The thing name. |
required |
Returns:
Type | Description |
---|---|
list
|
The result list of dict of 'get latest dweet for' API. |
from_bytes(msg)
#
Convert to str
with utf_8
codec.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg |
bytes
|
The message bytes to convert. |
required |
Returns:
Type | Description |
---|---|
str
|
Message string with |
to_bytes(msg)
#
Convert to bytes
with utf_8
codec.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg |
str
|
The message to convert. |
required |
Returns:
Type | Description |
---|---|
bytes
|
Message bytes with |