# A random number you already have: The stack address

DevFeed: [A random number you already have: The stack address](<https://devfeed.tech/articles/a-random-number-you-already-have-the-stack-address-35369.md>)

Original publisher: [Read original article](<https://darkcoding.net/software/a-random-number-you-already-have/>)

Author: Graham King

Published: 2022-06-05T23:19:39Z

Content type: article

Language: en

Sources: [Graham King](<https://devfeed.tech/sources/graham-king.md>)

Topics: [Linux](<https://devfeed.tech/topics/linux.md>), [Rust](<https://devfeed.tech/topics/rust.md>), [Python](<https://devfeed.tech/topics/python.md>), [macOS](<https://devfeed.tech/topics/macos.md>), [Security](<https://devfeed.tech/topics/security.md>), [Go](<https://devfeed.tech/topics/go.md>)

Tags: [go](<https://devfeed.tech/tags/go.md>), [linux](<https://devfeed.tech/tags/linux.md>), [macos](<https://devfeed.tech/tags/macos.md>), [number](<https://devfeed.tech/tags/number.md>), [performance](<https://devfeed.tech/tags/performance.md>), [python](<https://devfeed.tech/tags/python.md>), [random](<https://devfeed.tech/tags/random.md>), [rust](<https://devfeed.tech/tags/rust.md>), [security](<https://devfeed.tech/tags/security.md>), [software](<https://devfeed.tech/tags/software.md>), [stack](<https://devfeed.tech/tags/stack.md>)

## AI overview

This article explains how Address Space Layout Randomization can make a stack variable's memory address serve as a low-cost source of random bits. It describes address-bit handling in Rust and CPython, notes that the approach does not work the same way in Go, and connects the technique to hash-table randomization and denial-of-service resistance.

## Source excerpt

Thanks to Address Space Layout Randomization you can use the address of a stack variable as a zero-cost random number.