A method for detecting secrets in code using Byte-Pair Encoding (BPE) tokenization as a more effective alternative to entropy-based filtering. BPE measures how rare or non-natural a string is by tokenizing it—common words become single tokens while random strings fragment into many small tokens, better identifying actual secrets than traditional randomness metrics.