Complete Go implementation of POCSAG pager protocol with encoder and decoder, directly ported from pocsag-tool.
- β Full POCSAG encoder - Generate pager messages
- β Full POCSAG decoder - Decode pager messages from WAV files
- β BCH(31,21) error correction
- β Address encoding/decoding
- β BCD numeric message encoding (function 0)
- β 7-bit ASCII alphanumeric encoding (function 3)
- β WAV audio generation and decoding (48kHz, 512/1200/2400 baud)
- β AES-256/AES-128 encryption - Secure communications
- β Compatible with PDW and multimon-ng
- β JSON output support for API integration
# Install encoder
go install github.com/sqpp/pocsag-golang/cmd/pocsag@latest
# Install decoder
go install github.com/sqpp/pocsag-golang/cmd/pocsag-decode@latest
# Install burst encoder (multiple messages)
go install github.com/sqpp/pocsag-golang/cmd/pocsag-burst@latestOr build from source:
git clone https://github.com/sqpp/pocsag-golang.git
cd pocsag-golang
go build ./cmd/pocsag
go build ./cmd/pocsag-decode
go build ./cmd/pocsag-burstGenerate POCSAG messages as WAV audio files:
# Alphanumeric message (default)
pocsag --address 123456 --message "HELLO WORLD" --output message.wav
pocsag -a 123456 -m "HELLO WORLD" -o message.wav
# Numeric message (512 baud)
pocsag --address 999888 --message "0123456789" --function 0 --baud 512 --output numeric.wav
pocsag -a 999888 -m "0123456789" -f 0 -b 512 -o numeric.wav
# High speed message (2400 baud)
pocsag --address 123456 --message "FAST MSG" --baud 2400 --output fast.wav
pocsag -a 123456 -m "FAST MSG" -b 2400 -o fast.wav
# Encrypted message (AES-256)
pocsag --address 123456 --message "SECRET MESSAGE" --encrypt --key "mysecretkey" --output encrypted.wav
pocsag -a 123456 -m "SECRET MESSAGE" -e -k "mysecretkey" -o encrypted.wav
# JSON output (for API integration)
pocsag -a 123456 -m "TEST API" -o test.wav --jsonParameters:
--address/-a: Pager address (RIC) - REQUIRED- Note: POCSAG addresses are automatically rounded to multiples of 8 (e.g., 1234567 β 1234560)
--message/-m: Message text - REQUIRED--output/-o: Output WAV file (default:output.wav)--function/-f: Message type -0for numeric,3for alphanumeric (default:3)--baud/-b: Baud rate -512,1200, or2400(default:1200)--encrypt/-e: Enable AES-256 encryption--key/-k: Encryption key (required if--encryptis used)--json/-j: Output result as JSON
Decode POCSAG messages from WAV files:
pocsag-decode --input message.wav
pocsag-decode -i message.wav
# Specify baud rate
pocsag-decode -i message.wav --baud 512
pocsag-decode -i message.wav -b 2400
# JSON output (for API integration)
pocsag-decode -i message.wav --jsonOutput example:
POCSAG1200: Decoded messages:
Address: 123456 Function: 3 ALPHA Message: HELLO WORLD
JSON output example:
{
"success": true,
"messages": [
{
"address": 123456,
"function": 3,
"message": "HELLO WORLD",
"type": "alphanumeric"
}
],
"baud": 1200
}Send multiple messages in one transmission:
# Create JSON file with messages
cat > messages.json << 'EOF'
[
{"address": 123456, "message": "FIRST MESSAGE", "function": 3},
{"address": 789012, "message": "SECOND MESSAGE", "function": 3},
{"address": 345678, "message": "0123456789", "function": 0}
]
EOF
# Generate burst
pocsag-burst --json messages.json --output burst.wav
pocsag-burst -j messages.json -o burst.wav
# JSON output
pocsag-burst -j messages.json --json-output
pocsag-burst -j messages.json -joParameters:
--json/-j: JSON input file with message array - REQUIRED--output/-o: Output WAV file (default:burst.wav)--baud/-b: Baud rate -512,1200, or2400(default:1200)--json-output/-jo: Output result as JSON
JSON Format:
[
{
"address": 123456,
"message": "Your message here",
"function": 3
}
]address: Pager address (RIC)message: Message textfunction:0for numeric,3for alphanumeric
JSON Output Example:
{
"success": true,
"output": "burst.wav",
"messages": [
{
"address": 123456,
"function": 3,
"message": "FIRST MESSAGE",
"type": "alphanumeric"
},
{
"address": 789012,
"function": 3,
"message": "SECOND MESSAGE",
"type": "alphanumeric"
}
],
"baud": 1200,
"count": 2,
"size": 44844
}package main
import (
"os"
pocsag "github.com/sqpp/pocsag-golang"
)
func main() {
// Create alphanumeric message
packet := pocsag.CreatePOCSAGPacket(123456, "HELLO WORLD", pocsag.FuncAlphanumeric)
// Convert to WAV audio
wavData := pocsag.ConvertToAudio(packet)
// Save to file
os.WriteFile("output.wav", wavData, 0644)
}package main
import (
"fmt"
"os"
pocsag "github.com/sqpp/pocsag-golang"
)
func main() {
// Read WAV file
wavData, _ := os.ReadFile("message.wav")
// Decode messages
messages, err := pocsag.DecodeFromAudio(wavData)
if err != nil {
panic(err)
}
// Print decoded messages
for _, msg := range messages {
fmt.Println(msg.String())
}
}FuncNumeric(0) - Numeric messagesFuncAlphanumeric(3) - Alphanumeric messagesFrameSyncWord(0x7CD215D8) - POCSAG frame syncIdleCodeword(0x7A89C197) - Idle codeword
-
CreatePOCSAGPacket(address uint32, message string, function uint8) []byte- Creates a complete POCSAG packet with preamble, sync, address, and message
-
ConvertToAudio(pocsagData []byte) []byte- Converts POCSAG bytes to WAV audio (48kHz, 16-bit PCM, mono)
-
EncodeAddress(address uint32, function uint8) uint32- Encodes an address codeword with BCH and parity
-
Ascii7BitEncoder(message string) []byte- Encodes ASCII text to 7-bit format for alphanumeric messages
-
NumericBCDEncoder(message string) []byte- Encodes numeric strings to BCD format (supports 0-9, space, -, [, ], U)
-
DecodeFromAudio(wavData []byte) ([]DecodedMessage, error)- Decodes POCSAG messages from WAV audio data
-
DecodeFromBinary(data []byte) ([]DecodedMessage, error)- Decodes POCSAG messages from raw binary data
-
DecodeReader(r io.Reader) ([]DecodedMessage, error)- Decodes POCSAG from an io.Reader
type DecodedMessage struct {
Address uint32
Function uint8
Message string
IsNumeric bool
}POCSAG-GO supports modern encryption standards for secure communications:
- AES-256: Military-grade encryption (default)
- AES-128: High-security encryption (alternative)
- CRC32 Integrity Verification: Prevents message tampering
- Base64 Encoding: Ensures POCSAG protocol compatibility
- π Password-based key derivation using SHA256 hashing
- π‘οΈ Random IV generation prevents replay attacks
- β Message integrity verification with CRC32 checksums
- π Backward compatibility with non-encrypted messages
Original Message β Add CRC32 β AES-256 Encrypt β Base64 Encode β POCSAG Packet
POCSAG Packet β Base64 Decode β AES-256 Decrypt β Verify CRC32 β Original Message
# Create encrypted message
pocsag -a 123456 -m "SECRET MESSAGE" -e -k "mysecretkey" -o encrypted.wav
# JSON output shows encryption status
pocsag -a 123456 -m "SECRET MESSAGE" -e -k "mysecretkey" --jsonJSON Output Example:
{
"success": true,
"output": "encrypted.wav",
"address": 123456,
"function": 3,
"message": "SECRET MESSAGE",
"baud": 1200,
"encrypted": true,
"type": "alphanumeric",
"size": 133164
}- Key Management: Use strong, unique keys for each communication group
- Key Distribution: Securely share keys with intended recipients
- Compatibility: Encrypted messages appear as Base64-encoded data in multimon-ng
- Performance: Encryption adds minimal overhead to message processing
The generated WAV files are compatible with:
- PDW (Paging Decode for Windows)
- multimon-ng -
multimon-ng -t wav -a POCSAG1200 message.wav - multimon-ng -
multimon-ng -t wav -a POCSAG512 message.wav(512 baud) - multimon-ng -
multimon-ng -t wav -a POCSAG2400 message.wav(2400 baud)
Note: Our decoder properly handles message padding and strips null characters. Multimon-ng may occasionally display extra null characters for longer messages, but this doesn't affect the actual message content when decoded with our tools.
Encoder ported from pocsag-tool by hazardousfirmware.
BSD-2-Clause (same as original pocsag-tool)