> For the complete documentation index, see [llms.txt](https://andelf.gitbook.io/tron/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://andelf.gitbook.io/tron/tron-by-example/generate-address-offline.md).

# Generate Address Offline

## Python

```python
import ecdsa
import base58
import ecdsa
import random

from Crypto.Hash import keccak


def keccak256(data):
    hasher = keccak.new(digest_bits=256)
    hasher.update(data)
    return hasher.digest()


def get_signing_key(raw_priv):
    return ecdsa.SigningKey.from_string(raw_priv, curve=ecdsa.SECP256k1)


def verifying_key_to_addr(key):
    pub_key = key.to_string()
    primitive_addr = b'\x41' + keccak256(pub_key)[-20:]
    # 0 (zero), O (capital o), I (capital i) and l (lower case L)
    addr = base58.b58encode_check(primitive_addr)
    return addr


while True:
    raw = bytes(random.sample(range(0, 256), 32))
    # raw = bytes.fromhex('a0a7acc6256c3..........b9d7ec23e0e01598d152')
    key = get_signing_key(raw)
    addr = verifying_key_to_addr(key.get_verifying_key()).decode()
    print('Address:     ', addr)
    print('Address(hex):', base58.b58decode_check(addr.encode()).hex())
    print('Public Key:  ', key.get_verifying_key().to_string().hex())
    print('Private Key: ', raw.hex())

    break

```

## Rust

Ref: <https://github.com/andelf/rust-tron/blob/master/keys/src/address.rs>

## PHP

Ref: <https://github.com/tronprotocol/documentation/blob/master/TRX_CN/index.php>

## JavaScript

```javascript
const TronWeb = require('tronweb');

console.log(TronWeb.utils.accounts.generateAccount());
```

## Java

Ref: <https://github.com/ki5fpl/tronj/blob/master/client/src/main/java/com/github/ki5fpl/tronj/client/TronClient.java#L49>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://andelf.gitbook.io/tron/tron-by-example/generate-address-offline.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
