Skip to content

Commit

Permalink
Improve process of obfuscating wav file data
Browse files Browse the repository at this point in the history
  • Loading branch information
dapphp committed May 27, 2011
1 parent a39a022 commit c851eb5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion securimage.php
Expand Up @@ -897,6 +897,8 @@ protected function generateWAV($letters)
$out_data = substr_replace($out_data, pack('V', $filesize), 4, 4);
$out_data = substr_replace($out_data, pack('V', $numSamples), 40 + ($info['SubChunk1Size'] - 16), 4);

$this->scrambleAudioData(&$out_data, 'wav');

return $out_data;
}

Expand All @@ -911,12 +913,19 @@ protected function scrambleAudioData(&$data, $format)

$start += rand(1, 64); // randomize starting offset
$datalen = strlen($data) - $start - 256; // leave last 256 bytes unchanged

$step = 16;

for ($i = $start; $i < $datalen; $i += 64) {
$ch = ord($data{$i});
if ($ch < 9 || $ch > 119) continue;

$data{$i} = chr($ch + rand(-8, 8)); // slightly change value of the byte to create blips or distortions of sound

if ($format == 'wav') {
$step = rand(1, 16);
} else {
$step = 64;
}
}
}

Expand Down

0 comments on commit c851eb5

Please sign in to comment.