# Can't play vod URL affter hasing use Security token V2

**URL:** https://community.wowza.com/t/cant-play-vod-url-affter-hasing-use-security-token-v2/45467
**Category:** Wowza Streaming Engine
**Tags:** media-players-and-devices
**Created:** [June 15, 2015, 3:57pm UTC](https://community.wowza.com/t/cant-play-vod-url-affter-hasing-use-security-token-v2/45467 "2015-06-15T15:57:34Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Nguyen\_Viet\_nguyen](https://avatars.discourse-cdn.com/v4/letter/n/e56c9b/32.png) [@Nguyen\_Viet\_nguyen](https://community.wowza.com/u/Nguyen_Viet_nguyen)
#### Post date: [June 15, 2015, 3:57pm UTC](https://community.wowza.com/t/cant-play-vod-url-affter-hasing-use-security-token-v2/45467/1 "2015-06-15T15:57:34Z")

</div>

Sorry for my bad English.

I using Wowza Stream Engine and I Enable Outgoing security with SecurityToken Version 2.

My Application using C# on server to generate PLay URL

I do Step by step in this article: [https://www.wowza.com/docs/how-to-protect-streaming-using-securetoken-in-wowza-streaming-engine](https://www.wowza.com/docs/how-to-protect-streaming-using-securetoken-in-wowza-streaming-engine)

These is my Configuration:

Server Root Url: [http://192.168.1.107:1935](http://192.168.1.107:1935)

VOD ApplicationName: **vod**

Share Secret: **aaaa**

Query Prefix: **imv**

FilePath: sample.mp4

Option: Include client IP address in hash generation Is **On**

Client IP: **192.168.1.107**

And String for hash Generated: **vod/sample.mp4?192.168.1.107&aaaa**

I Use SHA256 for Encryption.

And this is may Result:[PHP][http://192.168.1.107:1935/vod/sample.mp4/playlist.m3u8?imvhash=94a7ad9755e8de92cfc68c69afc48ae02f1142fa9f5cd8b1fed2f5792d6d0c41[/PHP]](http://192.168.1.107:1935/vod/sample.mp4/playlist.m3u8?imvhash=94a7ad9755e8de92cfc68c69afc48ae02f1142fa9f5cd8b1fed2f5792d6d0c41%5B/PHP%5D)

I try to open this URL in VLC Player. But it not working for me.

Any help, please.

---

<div class="post-metadata">

### Author: ![Nguyen\_Viet\_nguyen](https://avatars.discourse-cdn.com/v4/letter/n/e56c9b/32.png) [@Nguyen\_Viet\_nguyen](https://community.wowza.com/u/Nguyen_Viet_nguyen)
#### Post date: [June 16, 2015, 1:16am UTC](https://community.wowza.com/t/cant-play-vod-url-affter-hasing-use-security-token-v2/45467/2 "2015-06-16T01:16:44Z")

</div>

Any help?

---

<div class="post-metadata">

### Author: ![Zoran](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/zoran/32/385_2.png) [@Zoran](https://community.wowza.com/u/Zoran)
#### Post date: [June 19, 2015, 11:08am UTC](https://community.wowza.com/t/cant-play-vod-url-affter-hasing-use-security-token-v2/45467/3 "2015-06-19T11:08:55Z")

</div>

Hi,

The calculated hash you are presenting here does not look like a URL-safe Base64 encoded string.

You should also Base64 encode the hashed string and replace the ‘+’ character with the ‘-’ character and the ‘/’ character with the ‘\_’ character.

> **hash**
> 
> (Required) The hash generated at the client as a URL-safe Base64-encoded string. URL-safe Base64 encoding replaces the ‘+’ character with the ‘-’ character and the ‘/’ character with the ‘\_’ character.
> 
> Example: wowzatokenhash=VSNlS5S2Na5KxwwiVLXIcHwC90CF2lHdmCm9v\_8Bh0o=
> 
> In PHP you can use something similar to this:
> 
> ```auto
> <?php
> $clientIP = null; // provide client IP optionally
> // $clientIP = $_SERVER['REMOTE_ADDR'];
> $host = "hostname.com"; // your ip/host
> $url= "http://".$host.":1935/";
> $stream = "live/myStream"; // your stream
> $start = time();
> $validity = 1000; // validity in seconds
> $end = time() + $validity;
> $secret = "00secret"; // your secret
> $tokenName = "wt";
> $params = array("{$tokenName}starttime=".$start, "{$tokenName}endtime=".$end, $secret);
> if(!is_null($clientIP)){
> $params[] = $clientIP;
> }
> sort($params);
> $string4Hashing = $stream."?";
> foreach($params as $entry){
> $string4Hashing .= $entry."&";
> }
> $string4Hashing = preg_replace("/(\&)$/","", $string4Hashing);
> $hash = hash('sha256', $string4Hashing, true); // generate the hash string
> echo $string4Hashing;
> echo "<br>";
> $base64Hash = strtr(base64_encode($hash), '+/', '-_'); // Base64 encode the hashed string
> $playbackURL = $url.$stream."/playlist.m3u8?".$tokenName."starttime=".$start.$tokenName."endtime=".$end.$tokenName."hash=".$base64Hash;
> echo $base64Hash;
> echo "<br>";
> echo $playbackURL;
> echo "<br>";
> ?>
> 
> ```
> 
> Zoran

---

<div class="post-metadata">

### Author: ![Paul\_Shields](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/paul_shields/32/390_2.png) [@Paul\_Shields](https://community.wowza.com/u/Paul_Shields)
#### Post date: [September 25, 2015, 10:41am UTC](https://community.wowza.com/t/cant-play-vod-url-affter-hasing-use-security-token-v2/45467/4 "2015-09-25T10:41:17Z")

</div>

Hi,

If wanted to access files in a sub-folder then be sure to use _definst_ when you construct your URL, for example

```auto
protocol://[wowza-address]:1935/[app-name]/_definst_/mp4:[path]/[stream-name]
[/url]
Paul

```

---

<div class="post-metadata">

### Author: ![Nguyen\_Viet\_nguyen](https://avatars.discourse-cdn.com/v4/letter/n/e56c9b/32.png) [@Nguyen\_Viet\_nguyen](https://community.wowza.com/u/Nguyen_Viet_nguyen)
#### Post date: [June 22, 2015, 5:31pm UTC](https://community.wowza.com/t/cant-play-vod-url-affter-hasing-use-security-token-v2/45467/5 "2015-06-22T17:31:29Z")

</div>

> Hi,
> 
> The calculated hash you are presenting here does not look like a URL-safe Base64 encoded string.
> 
> You should also Base64 encode the hashed string and replace the ‘+’ character with the ‘-’ character and the ‘/’ character with the ‘\_’ character.
> 
> In PHP you can use something similar to this:
> 
> ```auto
> <?php
> $clientIP = null; // provide client IP optionally
> // $clientIP = $_SERVER['REMOTE_ADDR'];
> $host = "hostname.com"; // your ip/host
> $url= "http://".$host.":1935/";
> $stream = "live/myStream"; // your stream
> $start = time();
> $validity = 1000; // validity in seconds
> $end = time() + $validity;
> $secret = "00secret"; // your secret
> $tokenName = "wt";
> $params = array("{$tokenName}starttime=".$start, "{$tokenName}endtime=".$end, $secret);
> if(!is_null($clientIP)){
> $params[] = $clientIP;
> }
> sort($params);
> $string4Hashing = $stream."?";
> foreach($params as $entry){
> $string4Hashing .= $entry."&";
> }
> $string4Hashing = preg_replace("/(\&)$/","", $string4Hashing);
> $hash = hash('sha256', $string4Hashing, true); // generate the hash string
> echo $string4Hashing;
> echo "<br>";
> $base64Hash = strtr(base64_encode($hash), '+/', '-_'); // Base64 encode the hashed string
> $playbackURL = $url.$stream."/playlist.m3u8?".$tokenName."starttime=".$start.$tokenName."endtime=".$end.$tokenName."hash=".$base64Hash;
> echo $base64Hash;
> echo "<br>";
> echo $playbackURL;
> echo "<br>";
> ?>
> 
> ```
> 
> Zoran

Hi Zoran.

Thanks for your help.

And If I Place my Video In subfolder of Wowza Root Directory. is THe Url generated like above.

FilePath: video\_2015-06-20/sample.mp4

Thanks.
