Passcode to lock Telegram

In order to set up a passcode, go to Telegram Settings — Privacy & Security — Passcode. Once you set up a passcode, a lock icon will appear in your chats list. Tap on it to lock the app — your passcode will be required next time you open Telegram. When the app is locked, text and sender's name are hidden in notifications.

You can also enable auto-lock in Passcode Settings, if you don't want to lock the app manually.

Auto-lock

If you don't want to lock the app manually, you can enable auto-lock in Passcode Settings. At the moment the smallest available setting is 1 minute, which works for most users — this way the app locks pretty quickly, but you don't need to key in the code if a new message arrives just as you've put the phone back in your pocket.

iOS

If you enable database encryption, the database with text chat messages will be encrypted. It may be possible that all the files will be encrypted at some point in the future, but for now one has to live with iOS' native data protection. For the local database Telegram for iOS is using standard AES-256 with PBKDF2 key derivation function.

Telegram Desktop

See here.