[Python] What Danger am I Inviting if I Store Telegram User IDs Unhashed/Unencrypted in a...

Discussão em 'Python' iniciado por Stack, Abril 18, 2025.

  1. Stack

    Stack Membro Participativo

    I am working on a bot that echoes the latest YT video title of a specific Youtube Channel to its users. However, it will only echo the video title only if it contains at least one of the user's inputted keywords. To ensure all users will receive the info at the roughly the same time, the bot has a global timer set to every hour.

    For instance:

    • User A, User B, and User C have different saved keywords, but they have "Deep learning" in common. Let's assume they are all under the same timezone. User A set his keywords at 1:20 PM, User B set his at 1:30 PM, and User C set hers at 1:55 PM
    • The global timer was set at 10:00 AM every hour, so they will all receive a message of the video title at 2:00 PM if the title contains "Deep learning"

    Currently, I am storing the Chat_ID (which is the same as User_ID because the bot is for private chat) and a string Keywords in the database. For security, I encrypted the keywords to prevent the potential mapping of user behavior. In other words, every other column except for the Chat_ID is encrypted. My concern presents itself as the title of this post. Since Chat_ID is unique, I am using it to index my database. If I were to hash it, I would lose the ability of quick lookups if the user ever wishes to update his/her current list of keywords.

    So: what danger am I inviting if I store telegram user IDs unhashed/unencrypted in a database?

    I did not foresee myself with this problem, so I initially hashed the Chat_ID/User_ID. I could generate a column specifically designed for indexing (PK and autoincrement), but what purpose does it serve if I cannot perform quick lookups with it?

    I am using Python 3.12, Python-Telegram-Bot, Sqlite3

    Continue reading...

Compartilhe esta Página